Source code filename – CPP11.CPP Turn in instructions: You will be uploading onl
ID: 3842255 • Letter: S
Question
Source code filename – CPP11.CPP
Turn in instructions: You will be uploading only the CPP11.CPP file to this myCourses drop box. Be sure to include General Requirements that are outlined in the General Requirements module.
Step 1: Define a series of variables. Use the most efficient data type for the variable according to the Data Types in C++ handout.
Step 2: Create a series of input and output statements to get data from the user (using the keywords we have used in class so far).
Step 3: Ouput the data contained in the variables.
The data will only print out to a limited number of decimal positions, so don’t worry if you input .123456789 and it only prints .123457 or some lesser number of positions. Also, output may be transformed to scientific notation by the output statement. This is OK. We will get to formatting output in a future chapter.
//include the header file IOSTREAM
use:
using namespace std;
//define the start of the function main
int main ()
{
//Step 1 (define all variables first)
//values come from user input via input statement….do NOT supply values with definition
//define a variable appropriate to hold the population of the US 300,000,000+
//define a variable appropriate to hold the average family income in the US 51,321.43
//define a variable appropriate to hold the hourly wage of 1 family member 17.98
//define a variable appropriate to hold the count of the total student attending SPC 30,609
//define a variable appropriate to hold the total GNP of Florida 754,256,198.95
//define a variable appropriate to hold a single character to represent person's gender
//Step 2 ( a series of questions getting input from the user, do not type in commas for values as in 123,123.00….it is typed as 123123.00)
//Create cout prompts asking the user to input a value for each of the variables – 1 cout per variable followed immediately by a cin to hold the user keyboard input value for the variable. You should inform the user not to enter commas!
//Step 3 (output all of the data to the screen)
//Create cout’s to put the value of each variable on the screen. If the number of decimal positions is different than you put in or it prints in scientific notation, it is still correct.
Make the program beep 5 times using escape sequences. You may only hear one beep…they are spaced too closely together for the human ear to differentiate if your computer has a really fast processor.
Explanation / Answer
Here is the code champ. Hope you will like it. If you dont like it, please let me know. I shall try my best to resolve all the issues you face.
#include<iostream>
using namespace std;
int main() {
//Step 1
long long population;
double avgIncome;
double hourlyWage;
int countStudent;
double GNP;
char gender;
//Step 2
cout << "Do not use comma while entering values" << endl;
cout << "Enter population of US: ";
cin >> population;
cout << "Enter average family income in the US: ";
cin >> avgIncome;
cout << "Enter the hourly wage of 1 family member: ";
cin >> hourlyWage;
cout << "Enter the count of the total student attending SPC: ";
cin >> countStudent;
cout << "Enter the total GNP of Florida: ";
cin >> GNP;
cout << "Enter a single character to represent gender: ";
cin >> gender;
//Step 3
cout << "Population of US: " << population << endl;
cout << "Average family income in the US: " << avgIncome << endl;
cout << "Hourly wage of 1 family member: " << hourlyWage << endl;
cout << "Total student attending SPC: " << countStudent << endl;
cout << "Total GNP of Florida: " << GNP << endl;
cout << "Gender: " << gender << endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.