Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

LAB 35 Student Generated Code Assignments OptionI Write a program that will read

ID: 3745110 • Letter: L

Question

LAB 35 Student Generated Code Assignments OptionI Write a program that will read in 3 grades from the keyboard and will print the average (to 2 decimal places) of those grades to the screen. It should include good prompts and labeled output. Notice in the sample run that the answer is stored in fixed point notation with two decimal points of precision. Sample run Sample run Please input the first grade 97 Please input the second grade 98.3 Please input the third grade 95 The average of the three grades s 96.77 Option 2: The Woody furniture company sells the following three styles of chairs: Style Price Per Chair American Colonial $ 85.00 Modern S 57.50 French Classical $127.75 Write a program that will input the amount of chairs sold for each style. It will print the total dollar sales of each style as well as the total sales of all chairs in fixed point notation with two decimal places Sample run Sample run Please input the number of American Colonial chairs sold 20 Please input the number of Modern chairs sold 15 Please input the number of French Classical chairs sold

Explanation / Answer

Option 1 answer:

#include <iostream>
#include <iomanip>
using namespace std;

// main function definition
int main()
{
// Variables to store grade
double grade1, grade2, grade3;
// Accepts the grades
cout<<" Please input the first grade: ";
cin>>grade1;
cout<<" Please input the second grade: ";
cin>>grade2;
cout<<" Please input the third grade: ";
cin>>grade3;
// Calculates the average and displays the average up to two decimal places

// setprecision(2) function is used to set 2 decimal places of <iomanip>
cout<<" The average of the three grades is = "<<fixed<<setprecision(2)<<(grade1 + grade2 + grade3)/3.0;
}// End of main function

Sample Output:

Please input the first grade: 97

Please input the second grade: 98.3

Please input the third grade: 95

The average of the three grades is = 96.77

Option 2 answer:

#include <iostream>
#include <iomanip>
using namespace std;

// main function definition
int main()
{
// Variables to store number of product sold
int no;

// To store total amount of each type
double totalAmerican, totalModern, totalFrench;

// Accepts the number of product sold for American Colonial
cout<<" Please input the number of American Colonial chairs sold: ";
cin>>no;
// Calculates the amount
totalAmerican = no * 85.00;

// Accepts the number of product sold for Modern
cout<<" Please input the number of Modern chairs sold: ";
cin>>no;
// Calculates the amount
totalModern = no * 57.50;

// Accepts the number of product sold for French Classic
cout<<" Please input the French Classic chairs sold: ";
cin>>no;
// Calculates the amount
totalFrench = no * 127.75;

// Displays the amount of each type up to two decimal places
// Function setprecision(2) of <iomanip> is used to display data up to 2 decimal places
cout<<" The total sales of American Colonial chairs $"<<fixed<<setprecision(2)<<totalAmerican;
cout<<" The total sales of Modern chairs $"<<fixed<<setprecision(2)<<totalModern;
cout<<" The total sales of French Classic chairs $"<<fixed<<setprecision(2)<<totalFrench;
cout<<" The total sales of all chairs $"<<fixed<<setprecision(2)<<(totalAmerican + totalModern + totalFrench);
}// End of main function

Sample Output:

Please input the number of American Colonial chairs sold: 20

Please input the number of Modern chairs sold: 15

Please input the French Classic chairs sold: 5

The total sales of American Colonial chairs $1700.00
The total sales of Modern chairs $862.50
The total sales of French Classic chairs $638.75
The total sales of all chairs $3201.25

Option 3 answer:

#include <iostream>
#include <iomanip>
using namespace std;

// main function definition
int main()
{
// Variables to store number of product sold
double totalSales;
// Variables to store state tax and local tax
double stateTax, localTax;

// Accepts the total sales
cout<<" Please input the total sales for each month: ";
cin>>totalSales;

// Accepts the state tax percentage
cout<<" Please input the state tax percentage in decimal form (.02 for 2%): ";
cin>>stateTax;

// Accepts the local tax percentage
cout<<" Please input the local tax percentage in decimal form (.02 for 2%): ";
cin>>localTax;

// Calculates and displays the total sales, state tax and local tax up to two decimal places
// Function setprecision(2) of <iomanip> is used to display data up to 2 decimal places
cout<<" The total sales for the month is $"<<fixed<<setprecision(2)<<totalSales;
cout<<" The sState tax for the month $"<<fixed<<setprecision(2)<<(totalSales * stateTax);
cout<<" The local tax for the month $"<<fixed<<setprecision(2)<<(totalSales * localTax);

}// End of main function

Sample Output:

Please input the total sales for each month: 1080

Please input the state tax percentage in decimal form (.02 for 2%): .06

Please input the local tax percentage in decimal form (.02 for 2%): .02

The total sales for the month is $1080.00
The sState tax for the month $64.80
The local tax for the month $21.60