Write C Program Inputs Contents File Line Line Outputs Line Console Program Starts Inputti Q43856576

Write a C++ program that inputs the contents of a file line byline, and outputs each line to the console. The program starts byinputting the name of the file from the keyboard, opens the file,and then checks to make sure the file was opened successfully. Ifnot, the program outputs “**file not found” and returns.

If the file was opened successfully, the program proceeds toread the file line by line, outputting each line to the consolealong with its line number. Assume each line of the input filecontains a single word. For example, suppose the file “input1.txt”contains the following:

apple

banana

pear

pizza

Given the filename “input1.txt”, your program should produce thefollowing output:

line 1: apple

line 2: banana

line 3: pear

line 4: pizza

main.cpp

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
string filename;

cout << “please enter filename> “;
cin >> filename; // input filename:
cout << endl;

//
// TODO:
//

return 0;
}

Expert Answer


Answer to Write a C++ program that inputs the contents of a file line by line, and outputs each line to the console. The program s…

Write C Program Load Two Column Numbers Arithmetic Operations Data Points Following Steps Q43844148

Write a c++ program toload two column of numbers, do arithmetic operations to the datapoints by following the steps below carefully. Output the computedresults to the specified output files

Steps to complete.

0. Download the datafile named Datafile1.data from the file area of the assignment.

1. Load two columns ofdata points, each column into a storage area, preferably avector.

2. Add each positionof the data and store it in another storage area.

3. Multiply eachposition of the data and store it to another storage area.

4. Write the resultsof addition and multiplication to file namedOutput-Multiplication.data and Output-Addition.data

Datafile1.data

9.144548371       0.62072663
7.766500067       1.107554175
6.428523445       0.409904615
4.864271967       1.142139412
7.064106885       1.138740729
2.262955152       1.198965847
9.800966285       0.624420569
8.466914743       0.172152387
7.089199692       0.650149663
6.042680886       0.526675179
1.320701358       0.893658642
3.576178301       0.966546628
4.939756105       0.53583099
3.386905283       0.24428521
5.231554752       0.660683916
3.736280728       0.378121052
7.527971435       0.917047269
2.533630929       1.029850114
9.188222671       0.237647807
1.800088589       0.763132902
9.702171329       1.187835787
4.713240732       0.602808579
0.350114291       0.126105779
1.375572924       0.534626533
3.699384174       0.670885379
7.183110563       1.327536861
7.434890545       1.174302317
9.781202522       1.271484048
7.153021655       0.99647769
0.516259776       0.868291689
9.637573135       0.596947716
7.056519481       0.350322259
0.160533268       0.565683307
9.008315924       0.919842547
9.173718748       0.593500412
6.921833783       0.015908284
6.736418485       0.719292318
3.353631576       1.363438995
1.604967361       0.679785674
5.672035588       0.171718917
7.794867595       0.550310846
5.889160186       0.07760882
1.690701207       0.829202546
4.155650455       0.94739278
6.018503489       0.989127529
1.46468541       1.171169011
2.670443291       0.505688273
8.22853784       0.514127061
9.631840542       0.238298413
1.669453846       1.27499486
3.311515543       0.789657118
5.969493897       0.053853209
2.478574394       1.206080543
7.696244495       0.099599082
3.769765061       1.193693451
1.992200015       0.895544331
4.030882115       0.398607671
2.939993773       0.360149058
8.499182913       0.645159168
1.33467738       0.264472403
3.475730127       0.826362657
7.471431245       1.220818624
6.140279634       0.462733534
3.740656241       1.363952935
5.174154405       1.157155608
9.466008548       0.261690906
9.225005657       0.158991829
7.061522707       0.200296564
2.527050453       0.668705617
3.989058951       0.659984653
5.969333965       0.297768248
6.813173789       1.23032852
7.47467435       0.289477322
0.27004337       0.808100642
0.226724804       0.947863653
8.491775489       0.703714179
9.67169797       0.439579426
7.171630039       0.893035833
8.435125276       0.053497387
1.740878827       1.135864744
1.624571489       0.537973501
9.398492585       1.285333242
9.855769556       1.156707773
5.536670988       0.524629176

COMPUTER SCIENCE…PLEASE HELP!!

Expert Answer


Answer to Write a c++ program to load two column of numbers, do arithmetic operations to the data points by following the steps be…

Write C Program Load Two Column Numbers Arithmetic Operations Data Points Following Steps Q43884091

Write a c++ program toload two column of numbers, do arithmetic operations to the datapoints by following the steps below carefully. Output the computedresults to the specified output files

Steps to complete.

0. Download the datafile named Datafile1.data from the file area of the assignment. (Donot change the file name to .txt. Open the file in notepad (win) orview/vi/vim (linux) or any viewer of your choice if you like to seethe data)

1. Create distinctfunctions for this project.

2. Load two columns ofdata points, each column into a storage area of a class where thedata storage is a vector .

3. Add each positionof the data and store it in another class where the data storage isa vector.

4. Multiply eachposition of the data and store it to another class where the datastorage is a vector.

5. Write the resultsof addition and multiplication to a file namedOutput-MultAdd-class.data and Output-Addition-class.data. Columnsof the output file is value1, value2, Addition, Multiplication in anicely formatted fashion.  

Datafile1.data

9.144548371       0.62072663
7.766500067       1.107554175
6.428523445       0.409904615
4.864271967       1.142139412
7.064106885       1.138740729
2.262955152       1.198965847
9.800966285       0.624420569
8.466914743       0.172152387
7.089199692       0.650149663
6.042680886       0.526675179
1.320701358       0.893658642
3.576178301       0.966546628
4.939756105       0.53583099
3.386905283       0.24428521
5.231554752       0.660683916
3.736280728       0.378121052
7.527971435       0.917047269
2.533630929       1.029850114
9.188222671       0.237647807
1.800088589       0.763132902
9.702171329       1.187835787
4.713240732       0.602808579
0.350114291       0.126105779
1.375572924       0.534626533
3.699384174       0.670885379
7.183110563       1.327536861
7.434890545       1.174302317
9.781202522       1.271484048
7.153021655       0.99647769
0.516259776       0.868291689
9.637573135       0.596947716
7.056519481       0.350322259
0.160533268       0.565683307
9.008315924       0.919842547
9.173718748       0.593500412
6.921833783       0.015908284
6.736418485       0.719292318
3.353631576       1.363438995
1.604967361       0.679785674
5.672035588       0.171718917
7.794867595       0.550310846
5.889160186       0.07760882
1.690701207       0.829202546
4.155650455       0.94739278
6.018503489       0.989127529
1.46468541       1.171169011
2.670443291       0.505688273
8.22853784       0.514127061
9.631840542       0.238298413
1.669453846       1.27499486
3.311515543       0.789657118
5.969493897       0.053853209
2.478574394       1.206080543
7.696244495       0.099599082
3.769765061       1.193693451
1.992200015       0.895544331
4.030882115       0.398607671
2.939993773       0.360149058
8.499182913       0.645159168
1.33467738       0.264472403
3.475730127       0.826362657
7.471431245       1.220818624
6.140279634       0.462733534
3.740656241       1.363952935
5.174154405       1.157155608
9.466008548       0.261690906
9.225005657       0.158991829
7.061522707       0.200296564
2.527050453       0.668705617
3.989058951       0.659984653
5.969333965       0.297768248
6.813173789       1.23032852
7.47467435       0.289477322
0.27004337       0.808100642
0.226724804       0.947863653
8.491775489       0.703714179
9.67169797       0.439579426
7.171630039       0.893035833
8.435125276       0.053497387
1.740878827       1.135864744
1.624571489       0.537973501
9.398492585       1.285333242
9.855769556       1.156707773
5.536670988       0.524629176

COMPUTER SCIENCE…PLEASE HELP!!

Expert Answer


Answer to Write a c++ program to load two column of numbers, do arithmetic operations to the data points by following the steps be…

Write C Program Named Primesh Display First N Prime Numbers Value N Input User Sample Outp Q43779014

Write a C program named as “prime.sh” to display first nprime
numbers. The value of n is input by user.
Sample output:

$cc -o prime prime.c
$./prime
Enter the value of n: 3
First 3 prime numbers are: 2 3 5
$./prime
Enter the value of n: 6
First 3 prime numbers are: 2 3 5 7 11 13

Expert Answer


Answer to Write a C program named as “prime.sh” to display first n prime numbers. The value of n is input by user. Sample output: …

Write C Program New Shop Opened Asked Create Automated Menu Ordering Items Hard Items Soft Q43780679

write C++ program for New shop is opened your are asked tocreate an automated menu for ordering items (Hard Items, Soft Items) online from the shop.

The scenario of making order is as follow:

1 – The customer need to choose either Hard or Soft :

– In case of Hard item the customer may choose (Hard Item One orHard Item Two).

– In case of Hard item the customer may choose (Soft Item One orSoft Item Two) .  

Note that:

– A full menu should be display for the customer .

– After ordering Hard the customer may order Soft .

– Bad input should be ignored .

– Welcome massage (Welcome to our Shop) and goodbye massage(Thanks come back again). should be used.

Inputs : Upper case Characters for choosing items from the menu.

Output: full Order (customer order Hard or Soft )

Output Example:

Welcome to our Shop

What do you want to buy today?

A) Hard Item B) Soft Item

Your order is :

Hard Item One

Soft Item Two

Thanks come back again

Expert Answer


Answer to write C++ program for New shop is opened your are asked to create an automated menu for ordering items (Hard Items, Soft…

Write C Program Performs Following Operations Sure Give Numeric Output Two Decimal Places Q43811760

Write a C programwhich performs the following operations (be sure to give allnumeric output to two decimal places):

Assigns a value(275.5) representing the distance in miles traveled by a car

Assigns a value (8.5)representing the number of hours taken to travel that distance

Computes the speed ofthe car in miles/hour (speed = distance/time)

Computes the speed ofthe car in meters/second (use 1 mile = 1600 meters)

Note: Do not performyour own calculations and have your program output the results. Allof the calculations for the lab should be performed within yourprogram. Use the following guidelines to develop your program:

Declare your variableswith appropriate data types.

Assign values to yourvariables.

Perform yourcalculations.

Generate appropriateoutput.

Expert Answer


Answer to Write a C program which performs the following operations (be sure to give all numeric output to two decimal places): As…

Write C Program Prints Multiplication Table Print Even Numbers Instance 1 2 1 4 1 6 1 8 1 Q43865354

write a C program that prints all themultiplication table and print just the even numbers ..

for instance :
1*2
1*4
1*6
1*8
1*10

2*2
2*4
2*6
….
so on

Expert Answer


Answer to write a C program that prints all the multiplication table and print just the even numbers .. for instance : 1*2 1*4 1*6…

Write C Program Prints Numbers 1 100 Multiples Three Point Print Fizz Instead Number Mult Q43877390

Write a c program that prints the numbers from 1 to 100 . Butfor multiples of three point print Fizz instead of the number andfor the multiples of five print Buzz. For numbers which aremultiples of both three and five print FizzBuzz.

Expert Answer


Answer to Write a c program that prints the numbers from 1 to 100 . But for multiples of three point print Fizz instead of the num…

Write C Program Processes Set Sales Data Program First Prompt User Number Months Sales Dat Q43907903

Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months of sThe bar chart (and suggested coordinates) generated for the example sales data is shown below: 250, 25 375, 26 C++ Graphics Qwhich results in an integer value of 0. Since the minimum allowable value for height is 1, reset height to 1 (not 0). ObserveRequired Functions The following functions are required when implementing this program. You are free to add any extra functiovoid displayResults (int sales[], int no_months, int max, int min, double avg); Displays the complete bar chart diagram as sh

SALES

Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months of sales data to process as shown below: Enter number of months to process: (between 3 and 6 inclusive):6 The minimum months that can be processed are 3, while the maximum number of months that can be processed is 6. A value of 6 is entered for the example given above. Next, the user is prompted for the sales data. The sales data should be stored as integer data within an integer array with the maximum number of elements set to 6. Any non- zero integer value is valid. Example sales data entry is shown below: Enter sales for month #1: 1250 Enter sales for month #20 100 Enter sales for month #3: 13000 Enter sales for month #4: 10000 Enter sales for month #5: 6000 Enter sales for month #6: 3000 For this example, month #1 corresponds to January, month #2 corresponds to February, and so on up to June corresponding to month #6. This program will next display the sales data in the form of a bar chart. The bar chart that this program generates consists of the following: 1. An x/y axis 2. Rectangles representing the percentage of sales for a given month 3. The given month’s abbreviation displayed above its rectangle 4. An image and text used as the bar chart’s heading/title 5. An informational box containing a summary of the sale’s data statistics The bar chart (and suggested coordinates) generated for the example sales data is shown below: 250, 25 375, 26 C++ Graphics QOX Sales for 6 months SALES Monthly Sales May June 200, 280 Feb Months Sales Statistics 200, 345 – 205, 380 Max Sales: $13000 Min Sales: $100 Avg Sales: $5558 Note that the height of each rectangle is based on the sales for that given month. The equation for computing the height for each rectangle is: height = ((double) sales[i]/max) *100.0; where sales[i] is the ith sales value, and max is the maximum sales value (for this example its 13000). The variable height is measured in pixels and should be declared as an int. The minimum value for height is set to 1 (not 0). In other words, if height<1, reset it to exactly 1. The suggested width of each rectangle is 50. The suggested horizontal distance between each rectangle is 25. The suggested length of the vertical axis is 150px while the suggested length of the horizontal axis is 440px. Note: For this example, the height for Feb is computed as height = (100/13000)*100 which results in an integer value of 0. Since the minimum allowable value for height is 1, reset height to 1 (not 0). Observe that there is a very small green rectangle under the Feb heading that has a height of only 1 pixel. This is due to the sales for the month of Feb is < 1. Each month’s rectangle should be colored as follow: January – Red (255,0,0) February – Green (0,255,0) March – Blue (0,0,255) April – Yellow (255,255,0) May – Magenta (255,0,255) June – Turquoise (0,255,255) The heading area of the bar graph should contain an image (sales.bmp) and a text string. sales1.bmp is shown below: The text string portion of the title should indicate the number of months being processed. For this example, the number of months is 6, and the title string appears as: Sales for 6 months The month’s abbreviation should be displayed at the upper left edge of each rectangle. The month’s abbreviations for this program are shown below: Month January February March April May June Abbreviation Jan Feb Mar Apr May June The sales statistics consist of the following: Max Sales Min Sales Average Sales All statistics should be computed as integer values (this includes the Average Sales too). Required Functions The following functions are required when implementing this program. You are free to add any extra functions that you like. int getNoMonths(); Prompts the user for the number of months to process for the sales data. Valid entries are between 3 and 6 inclusively. Return Value: An integer corresponding to the number of months void get Sales (int sales[], int no_months); Prompts the user for the sales data. Correspoinding data is stored in parameters sales. Parameter: no_months – Number of months of sales data to process. Parameter: sales – Array of integers used for storing the sales data as entered by the user. Any positive integer (including zero) is valid. int getMax (int sales [], int no_months); Determines the maximum value from the array of sales. Paramter: sales – Array of integers containing the sales data. Parameter: no_months – Number of months of sales data to be processed. Return Value: The maximum value stored in the sales array int getMin(int sales[], int no_months); Determines the minimum value from the array of sales. Parameter: sales – Array of integers containing the sales data. Parameter: no months – Number of months of sales data to be processed. Return Value: The minimum value stored in the sales array double getAverage (int sales[], int no_months); Computes the average of all sales stored in the sales array. Parameter: sales – Array of integers containing the sales data. Parameter: no_months – Number of months of sales data to be processed. Return Value: The average computed over all values stored in the sales array. void displayResults (int sales[], int no_months, int max, int min, double avg); Displays the complete bar chart diagram as shown on page 2. Use all specifications provided in the overviw section on page 2. Parameter: sales – Array that contains the sales data used for generating the bar char. Parameter: no_months – Number of months (i.e., entries) of sales data to be processed. Should be between 3 and 6 inclusively. Parameter max: The maximum sales value (as determined by getMax). Parameter min: The minimum sales values (as determined by getMin). Parameter avg: The average sales value (as computed by getAverage) Special Note The example screen capture is provided only as an example of what the results should look like. You will not be deducted points if your results are not identical to the one shown (your results should be neatly done and readable though). SALES Show transcribed image text Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months of sales data to process as shown below: Enter number of months to process: (between 3 and 6 inclusive):6 The minimum months that can be processed are 3, while the maximum number of months that can be processed is 6. A value of 6 is entered for the example given above. Next, the user is prompted for the sales data. The sales data should be stored as integer data within an integer array with the maximum number of elements set to 6. Any non- zero integer value is valid. Example sales data entry is shown below: Enter sales for month #1: 1250 Enter sales for month #20 100 Enter sales for month #3: 13000 Enter sales for month #4: 10000 Enter sales for month #5: 6000 Enter sales for month #6: 3000 For this example, month #1 corresponds to January, month #2 corresponds to February, and so on up to June corresponding to month #6. This program will next display the sales data in the form of a bar chart. The bar chart that this program generates consists of the following: 1. An x/y axis 2. Rectangles representing the percentage of sales for a given month 3. The given month’s abbreviation displayed above its rectangle 4. An image and text used as the bar chart’s heading/title 5. An informational box containing a summary of the sale’s data statistics
The bar chart (and suggested coordinates) generated for the example sales data is shown below: 250, 25 375, 26 C++ Graphics QOX Sales for 6 months SALES Monthly Sales May June 200, 280 Feb Months Sales Statistics 200, 345 – 205, 380 Max Sales: $13000 Min Sales: $100 Avg Sales: $5558 Note that the height of each rectangle is based on the sales for that given month. The equation for computing the height for each rectangle is: height = ((double) sales[i]/max) *100.0; where sales[i] is the ith sales value, and max is the maximum sales value (for this example its 13000). The variable height is measured in pixels and should be declared as an int. The minimum value for height is set to 1 (not 0). In other words, if height

Expert Answer


Answer to Write a C++ program that processes a set of sales data. Your program will first prompt the user for the number of months…

Write C Program Read 10 Numbers Keyboard Find Sum Average Use Loop Try Make Solution Brief Q43835936

Write a C program to read 10 numbers fromkeyboard and find their sum and average.
(Use a loop) , Try to make the solution as brief as youcan

Expert Answer


Answer to Write a C program to read 10 numbers from keyboard and find their sum and average. (Use a loop) , Try to make the soluti…