Modify Counter into a program that tells you only the number of lines that are a) shorter than ten characters and b) longer than twenty. Complete the following file: counter.cpp 1 #include 2 #include 3 using namespace std; 4 int main() 6 { 5 int charcount{0}; int lineCount{0}; char ch; while (cin.get(ch)) { charcount++; if (ch == '\n') { 7 8 10 11 12 13 14 15 lineCount++; } } cout <« charcount <« " characters read, "; cout <« lineCount « " lines read."; } 16 17 18 19 20 Submit
Q: Please use JAVA code to write the solution, thanks A text file called names.txt contains one name…
A: Java Code for the given question :- import java.io.*;import java.util.*;class Main { public…
Q: g point parts ingle(float f) that will print the parts of the floating point number as disti like:…
A: #include <iostream> using namespace std; // function to convert decimal to binary void…
Q: #include #include void LineFunc(void); void main() { int a, b; printf("Enter a :"); scanf_s("%d",…
A: The program after compilations gives an error that is So the error in this has occurred due to…
Q: All parts need to be included in the same C file so the new code needs to be added to the existing…
A: Please find the answer below:
Q: What will happen when we compile and run the following code? #include using namespace std; int…
A: Please find the answer below :
Q: Q3) By using IF-Statement, write a program to di splay the name of day by giving the day number as…
A: As no programming language is mentioned, it is solved using basic C++
Q: Q-No.6: Write the output of the following program. (1 tinclude *include using namespace std; class…
A: First, the program controller goes to the main() function. Then the object os String class is…
Q: Write a program that uses the sizeof operator to determine the sizes in bytes of the various data…
A: Given that we have to make a program that has to print the size of datatype on screen and save that…
Q: Can anyone help me to transfrom the code below to PYTHON code? Thanks a lot #include using…
A:
Q: Question: Write a program called commasperiods.c which reads through the file commasperiodsin.txt…
A: Given:
Q: #include #include int LineFunc(void); int main() { int a, b; printf("Enter a :"); scanf("%d", &a);…
A: In code draws a line which is in the form of y = mx+c The input to the code is a and b where a = m…
Q: #include int pqr(int, int); int main() { int x=pqr(20,2); printf("%d",x); return 0; int pqr(int…
A: Well Lets understand the function pqr int pqr(int x ,int y){ if(x==0) return 0; else…
Q: QUESTION 12 Multiple Choice: What is the output of the code below? public static void main(String]…
A: Question 12: class HelloWorld { public static void main(String[] args) { String str…
Q: I got this error message for the following C program: "Segmentation fault (core dumped)" QUESTION:…
A: The error message "Segmentation fault (core dumped)" can appear because the file does not exist in…
Q: nt st nat des omnile
A: #include <iostream> using namespace std; // function to convert decimal to binary void…
Q: NEED HELP PLEASE! Write a Java program to read a text file (command line input for file name),…
A: import java.io.*; public class Test{ public static void main(String[] args) throws IOException {…
Q: Based on the Program Q3 source code, modify the program by using the while loop. Program Q3 1.…
A: Given: Given the program in Do while we have to convert in while loop.
Q: 3. Count Even N(from codeChum, modified) by Catherine Arellano Write a program that will receive a…
A: int getNum(){ int n; scanf("%d", &n); }
Q: void copy (int& a, int& b, int& c) { a *= 2; b*= 2; c*= 2; int main () { int x = 2, y = 5, z = 7;…
A: Given: We have the c program given in which we have to find out the return values.
Q: I'm getting an error message where the FindText() is returning 0 instead of the proper amount of…
A: Coded in C++.
Q: Unfortunately, the change from int to Month means that it's harder to read Date objects from an…
A: Month toMonth ( int mm) C++ functionis given below
Q: What is the output of the following code? const int SIZE 5; int count;int time[SIZE] = {1, 2, 3, 4,…
A: in the above code snippet a variable named 'size' is created with constant value 5 now in second…
Q: Consider records of employees each consists of employee's first name (string), number of hours…
A: I give the code in python along with output and code screenshot
Q: to
A: #include <iostream> using namespace std; // function to convert decimal to binary void…
Q: int powa(int x, int n) { (n=1){ return x; } else { return x* powa(x, n - 1); void main( { int val;…
A: We have to find the content of stack while executing in powa function.
Q: #include #include int LineFunc(void); int main() { int a, b; printf("Enter a :"); scanf("%d", &a);…
A: Edited code for the above C program #include <stdio.h> #include <stdlib.h> void…
Q: Some word games require the player to find words that can be formed using the letters of another…
A: By making letter histograms of both words and comparing them according to the number of characters,…
Q: Modify task1.c so it will read from standard input, convert lowercase letters to uppercase letters,…
A: C program, read from standard input converting lowercase into uppercase letter and write standars…
Q: Write a code fragment where you read user’s entries from the keyboard into three variables - an item…
A: Note: Answering in python as no language is mentioned. Input : item ID (int) item name (string)…
Q: // Cornwall.cpp - This program computes hotel guest rates.// Input: None// Output: Hotel guest…
A: Actually, c++ is a powerful general purpose language. It is a high level language.
Q: Write a program called StudentTable that prints the below table. Use only print() or printf(). DO…
A: Code: #include<stdio.h>int main() { char h[4][50]={"Name","Lab","Bonus","Total"}; char…
Q: For the code given below, can you break down what algorithm is being displayed in the given code,…
A: Algorithm for that program
Q: Write a few statements that open a file called "words" and writes the last word in the file to a…
A: Given: C-program regarding file manipulation Objective: This program should open a file naming…
Q: Write a program that uses the sizeof operator to determine the sizes in bytes of the various data…
A: The complete solution is given below:
Q: What is wrong with the next programming? #include #include using namespace std; int main(){…
A: According to the question below the Solution: Error:
Q: Examine this code: Date d = makeDate(Month::jul, 4, 1776); Now that you've changed the type of…
A: The code fails not due to makeDate() function, it fails only due to isLeapYear() method generated by…
Q: Python's error handling process includes the finally clause. In the following code snippet, when is…
A: Try statement have an option finally Clause which is used to release external sources
Q: #include #include int LineFunc(void); int main() { int a, b; printf("Enter a :"); scanf("%d", &a);…
A: In this code, a line in the form of y = mx + c is drawn. Here, c is the intercept part, and m =…
Q: 2. Write a program that automates the table used by a surveyor to transform compass headings in…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: What will be the value stored in variables "num2" and "num3" after executing the following code…
A: #include <iostream>#include <cmath> using namespace std; int main() {…
Q: 1. Write a program to compeer between the value A and B ,when Ais greater than B it is display a…
A: "Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: Find the output of the following program. Assuming all the desired header files are already…
A: #include <iostream> using namespace std; struct Dimensions { int x_cord, y_cord; }; void…
Q: Finding Errors. Identifying the line/s containing errors that can cause the program not to run.…
A: The solution to the given problem is below.
Q: include int main(){ int a, b=3; double x=5.0, y; for (a=1; a -2) { b=b-a; printf ("%d%d\n", a, b); }…
A: Here intially b=3 Inside for loop: a= 1: If condition (b>-2) holds True so b=b-a => b=2…
Q: In Python, Use number.txt file (below). create a program that opens num.txt, a file consisting of a…
A: The above question is solved in step 2 :-
Q: Modify Counter into a program that tells you only the number of lines that are a) shorter than ten…
A: for implementing given problem, that will tell us number of lines that are shorter than 10…
Q: The Mastermind game board game is a code breaking game with two players. One player (your program)…
A: import randomsecretCode =[]for i in range (0,4): n = random.randint(1,9)…
Q: Practice Write named a program as getMostFreq.c o Takes input text file as arguments o Outputs the…
A: #include <stdio.h>#include <string.h>#include <ctype.h> #define size 10000 /*…
C++
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Below this question is a generated text representing a DNA sequence. The first line starts with '>' and is a comment, and the lines after that hold the sequence. The sequence has letters 'A', 'C', 'T', and 'G'. In your program (written in python) for this question, read the sequence using the statements: f = open('kdpF.txt') # opens a file for reading line = f.readline() # reads a single line print(line) seq = ''for line in f : # reading the rest of the lines seq = seq + lineseq = seq.replace('\n', '') # removing the newline characters seq = seq.upper() print(seq) def gcContent(sequence) : # You do the rest pass Also write a function gcContent(sequence), which returns the percent of the sequence which is either 'G' or 'C'. Use your function on the input sequence and print the results. generated text DNA sequence: >200 bp region of the chromosome of E. coli, containing gene kdpF, shortest…Write a program that will read in a file of student academic credit data and create a list of students on academic warning. The list of students on warning will be written to a file. Each line of the input file will contain the student name (a single String with no spaces), the number of semester hours earned (an integer), the total quality points earned (a double). The following shows part of a typical data file: Smith 27 83.7 Jones 21 28.35 Walker 96 182.4 Doe 60 150 The program should compute the GPA (grade point or quality point average) for each student (the total quality points divided by the number of semester hours) then write the student information to the output file if that student should be put on academic warning. A student will be on warning if he/she has a GPA less than 1.5 for students with fewer than 30 semester hours credit, 1.75 for students with fewer than 60 semester hours credit, and 2.0 for all other students. The file Warning.java contains a skeleton of the…Write a program that will read in a file of student academic credit data and create a list of students on academic warning. The list of students on warning will be written to a file. Each line of the input file will contain the student name (a single String with no spaces), the number of semester hours earned (an integer), the total quality points earned (a double). The following shows part of a typical data file: Smith 27 83.7 Jones 21 28.35 Walker 96 182.4 Doe 60 150 The program should compute the GPA (grade point or quality point average) for each student (the total quality points divided by the number of semester hours) then write the student information to the output file if that student should be put on academic warning. A student will be on warning if he/she has a GPA less than 1.5 for students with fewer than 30 semester hours credit, 1.75 for students with fewer than 60 semester hours credit, and 2.0 for all other students. The file Warning.java contains a skeleton of the…
- Write a line-by-line explanation of the code: #include <unistd.h>#include <sys/stat.h>#include <sys/types.h>#include <stdio.h>#include <stdlib.h>#include <time.h>char * errormsg[] = {"\nUsage: ./12filestat <file|dir> [<file|dir>]\n\n", "\nFile does not exist !!\n\n", "\nError doing 'stat' on file\n\n"};void printerror(int msgnum, int exitcode, int exitflag);int main(int argc, char *argv[]){int i;mode_t fileperm;struct stat filedetails;char successmsg[] = "\nCommand executed successfully\n\n";if ( argc < 2 )printerror(0,2,1);for ( i = 1; i < argc; i++ ){printf("\n%s\n%s\n%s\n","----------------",argv[i],"----------------");if ( access(argv[i],F_OK) == -1 ){printerror(1,3,0);continue;}if ( lstat(argv[i],&filedetails) < 0 ){printerror(2,4,0);continue; }if ( S_ISREG(filedetails.st_mode) )printf("File type : Regular\n");else if ( S_ISDIR(filedetails.st_mode) )printf("File type : Directory\n");else if ( S_ISLNK(filedetails.st_mode)…Write a program that reads by asking the user the name of the file. After opening it, read it into the structure of array. The input file is in the format: firstName lastName age result (Contents of the input file) The Temp 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 Edward Newman 61 3 1 2 2 2 3 5 3 5 3 5 1 3 1 4 3 5 2 5 3 5 1 3 1 5 1 5 3 1 1 3 1 3 1 3 3 5 2 1 2 3 5 1 1 3 3 5 3 1 5 The program reads the result into the structure called TheResult. The constants and the structure to be used is given below: const int EXTROVERSION = 0; const int AGREEABLENESS = 1; const int CONSCIENTIOUSNESS = 2; const int NEUROTICISM = 3; const int OPEN_TO_EXPERIENCE = 4; const int NUM_QUESTIONS = 50; const int NUM_RESULT = 5; const int MAX_RESULT = 5; struct TheResult { string firstName; string lastName; int age; int answers[NUM_QUESTIONS]; // result double normalizedResult[NUM_RESULT]; }; The name of the input file is…Hello,I got this error message for the following C program: the contents of words.txt file are: Segmentation fault (core dumped) QUESTION: Write a few statements that open a file called "words" and writes the last word in the file to a file called "lastword". PROGRAM: #include <stdio.h> int main(void) { char ch,file_name[25]; FILE *fp,*fn; char name[20]={"lastword"}; int i; fp=fopen("words.txt","a"); fprintf(fp,"%s\n",name); fclose(fp); fopen("words.txt","r"); printf("the contents of words.txt file are:\n"); while((ch=getc(fp)!=EOF)) { fprintf("%c",ch); } fclose(fp); fp=fopen("f://words.txt","r"); fn=fopen("f://lastword.txt","w"); while((fgets(file_name,25,fp))!=NULL) { printf("%s\n",file_name); if(strcmp(name,file_name)==0) { fprintf(fn,"%s/n",file_name); } } fclose(fp); fclose(fn); }
- C++ text 284.12223.09579.12998.651237.84764.75395.65458.01670.353765.003842.10190.23335.35662.952719.253564.02193.23222.231457.2089.751323.65234.35789.89224.67663.95245.38 Write a program that reads from a text file named “sales.txt”, which contains the sales figures (double) of a store. Your program should: Display the average, the highest, and the lowest sales figures Remember to: Test the file open error Close the file at the end.This is for Python version 3.8.5 and please include pseudocode. A file named gang.txt is shown below. Write Python code that opens this file, reads only the first two lines, and prints “Penny is 19” gang.txt (contents of file) - please create on with the data provided in order to complete this question. Thank you! Penny 19 Kenny 20 Benny 21 Jenny 20The problem is the following : Write a program that asks the user for the name of a file. The program should display the contents of the file with each line preceded with a line number followed by a colon. The line numbering should start at 1. Please edit this scanner to JOptionPane. I don't really know how to do that. //Java Program by Yuiri Fujita and Darrick Drewry 10/30/2020 import java.util.Scanner;import java.io.*; public class LineNumbers { public static void main(String[] args) throws IOException {// TODO Auto-generated method stubScanner input = new Scanner(System.in);String userFileName;System.out.println("Please enter the name of the file.( Enter LineNumbers.txt)");userFileName = input.nextLine();File file = new File( userFileName);while( !file.exists() ){System.out.println( userFileName + " does not exist. Please enter a different file name");userFileName = input.nextLine();file = new File ( userFileName);}Scanner fileToScan = new Scanner (file);String line;int counter =…
- Please in java , I cant get the output for t totalsalesforweek// b. avgsalesforweek// c. totalsalesforallweeks// d. averageweeklysales// e. weekwithhighestsaleamt// f. weekwithlowestsaleamt// analyzeresults //call a through f Write a program that opens the salesdat.txt file and processes it contents. The program should display the following per store: The total sales for each week. (Should print 5 values - one for each week). The average daily sales for each week. (Should print 5 values - one for each week). The total sales for all the weeks. (Should print 1 value) The average weekly sales. (Should print 1 value) The week with the highest amount in sales. (Should print 1 week #) The week with the lowest amount in sales. (Should print 1 week #) All Values (Total Sales, Average Daily Sales for Each Week, Total Sales for all Weeks, Average Weekly Sales, Highest Amount in Sales, Lowest Amount in Sales) The file contains the dollars amount of sales that a retail store made each day for…#include <iostream>using namespace std; char* duplicateWithoutBlanks(char *word){int len = sizeof(word); char *new_str = new char[len + 1]; int k = 0; for (int i = 0; i < len; ++i){if (word[i] != ' ')new_str[k++] = word[i];} new_str[k] = '\0'; return new_str;} int main(){// Testing code char word[] = "Hello, World!"; char* result = duplicateWithoutBlanks(word); cout<< "word: "<< word<< "\nResult: "<< result; ; return 0;} What to change to out put the same word without blank?This is a python file Fix this code and the output is the attachment #filename: modValidateEmail.py def isValidMSUMEmail(email): if email.count('@') != 1: return False tmp= email.split('@') if len(tmp) == 0: return False userName = tmp[0] if not userName[0].isalpha(): return False for c in userName: if not c.isalpha() and c != '.': return False inst= tmp[1] if inst != 'mnstate.edu': return False else: return True #filename: UnitTestValidEmail.py from unittest import * from modValidateEmail import * class TestValidEmail(TestCase): #create a subclass of unittest.TestCase def testUserName(self): self.assertEqual(isValidMSUMEmail('.joe@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe4@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe$smith@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe.smith@mnstate.edu'),True) def…