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

This is C++! Write a C++ program to display a hot beverage menu and prompts the

ID: 3721943 • Letter: T

Question

This is C++!

Write a C++ program to display a hot beverage menu and prompts the user to make a selection. A switch statement determines which item the user has chosen. A do-while loop repeats until the user selects item E from the menu to exit, any other selection should display the item selected and the price. The choices and prices are:

Coffee    $1.00

Tea $ .75

Hot Chocolate $1.25

Cappuccino $2.50

Latte $3.75

Solution (paste your code below)

Write a C++ program that manage the student’s grades. Starting with a fixed number of students (use 10 for simplicity) the user will input the grades for each student. The number of grades is given by the user. The grades are stored in an array. Two functions are called for each student. One function will give the numeric average of their grades. The other function will give a letter grade to that average. Grades are assigned on a 10-point spread.

90-100 A  

80- 89 B

70-79 C  

60-69 D  

Below 60 F

Solution (paste your code below)

Chould you please be kind enough and tyoe these code in detail? Thank you and have a good one!

Explanation / Answer

Write a C++ program to display a hot beverage menu and prompts the user to make a selection. A switch statement determines which item the user has chosen. A do-while loop repeats until the user selects item E from the menu to exit, any other selection should display the item selected and the price. The choices and prices are:

Coffee    $1.00

Tea $ .75

Hot Chocolate $1.25

Cappuccino $2.50

Latte $3.75

Solution (paste your code below)

--------------------------------------------------

CODE:

---------

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
//declaration of variables
int numCups; //number of cups
float cost;
char beverage; //the choices user have
bool validBeverage; //for checking if the input given by user is valid or not

cout<< fixed << showpoint << setprecision(2);

//Using do while loop and switch statment
do
{
//Prompts the user to input
cout<< endl << endl;
cout<< "***Hot Beverage Menu***" << endl << endl;
cout<< "A: Coffee $1.00" << endl;
cout<< "B: Tea $ .75" << endl;
cout<< "C: Hot Chocolate $1.25" << endl;
cout<< "D: Cappuccino $2.50" << endl;
cout<< "L:Latte $3.75" << endl;
cout<< "E: Exit the program " << endl;

cout<< "Enter the beverage A,B,C,D or L you desire" < << " (or E to exit the program): ";
cin>> beverage;


validBeverage = false;

switch(beverage)
{
case 'a':
case 'A': cost = 1.00;
validBeverage = true;
break;
case 'b':
case 'B': cost = .75;
validBeverage = true;
break;
case 'c':
case 'C': cost = 1.25;
validBeverage = true;
break;
case 'd':
case 'D':cost = 2.50;
validBeverage = true;
break;
case 'l':
case 'L':cost = 3.75;
validBeverage = true;
break;
case 'e':
case 'E': cout<< "Please come again"<< endl;
break;

default : cout<< "That's not on the menu."; }

//Using if statment to display the output and the cost of the order choosen by user
if (validBeverage)
{
cout<< "How many cups would you like ? ";
cin>> numCups;
cout<<"Your Total cost is: $"
<< cost*numCups }
}while(beverage != 'E' && beverage != 'e');

//closing
cout << " End of Program ";
return 0;
}

OUTPUT:

***Hot Beverage Menu***

A: Coffee $1.00

B: Tea $ .75

C: Hot Chocolate $1.25

D: Cappuccino $2.50

L:Latte $3.75

E: Exit the program

Enter the beverage A,B,C,D or L you desire
(or E to exit the program): a
How many cups would you like ? 3
Your Total cost is: $3.00

***Hot Beverage Menu***

A: Coffee $1.00

B: Tea $ .75

C: Hot Chocolate $1.25

D: Cappuccino $2.50

L:Latte $3.75

E: Exit the program

Enter the beverage A,B,C,D or L you desire
(or E to exit the program): e
Please come again

----------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------

Write a C++ program that manage the student’s grades. Starting with a fixed number of students (use 10 for simplicity) the user will input the grades for each student. The number of grades is given by the user. The grades are stored in an array. Two functions are called for each student. One function will give the numeric average of their grades. The other function will give a letter grade to that average. Grades are assigned on a 10-point spread.

90-100 A  

80- 89 B

70-79 C  

60-69 D  

Below 60 F

Solution (paste your code below)

Here the code is for as many students you can enter not specially 10.

#include <iostream>

#include <iomanip>

using namespace std;

const int MAXGRADE = 25; // maximum number of grades per student

const int MAXCHAR = 30; // maximum characters used in a name

typedef char StringType30[MAXCHAR + 1]; // character array data type for names

// having 30 characters or less.

typedef float GradeType[MAXGRADE]; // one dimensional integer array data type

float findGradeAvg(GradeType, int); // finds grade average by taking array of

// grades and number of grades as parameters

char findLetterGrade(float); // finds letter grade from average given

// to it as a parameter

int main()

{

StringType30 firstname, lastname; // two arrays of characters defined

int numOfGrades; // holds the number of grades

GradeType grades; // grades defined as a one dimensional array

float average; // holds the average of a student's grade

char moreInput; // determines if there is more input

cout << setprecision(2) << fixed << showpoint;

// Input the number of grades for each student

cout << "Please input the number of grades each student will receive." << endl

<< "This must be a number between 1 and " << MAXGRADE << " inclusive"

<< endl;

cin >> numOfGrades;

while (numOfGrades > MAXGRADE || numOfGrades < 1)

{

cout << "Please input the number of grades for each student." << endl

<< "This must be a number between 1 and " << MAXGRADE

<< " inclusive ";

cin >> numOfGrades;

}

// Input names and grades for each student

cout << "Please input a letter 'y 'if you want to input students"

<< " any other character will stop the input" << endl;

cin >> moreInput;

while (moreInput == 'y' || moreInput == 'Y')

{

cout << "Please input the first name of the student" << endl;

cin >> firstname;

cout << endl << "Please input the last name of the student" << endl;

cin >> lastname;

for (int count = 0; count < numOfGrades; count++)

{

cout << endl << "Please input a grade" << endl;

cin >> grades [count];

}

cout << firstname << " " << lastname << " has an average of ";

cout << findGradeAvg(grades, numOfGrades);

cout <<" which gives the letter grade of " << findLetterGrade(findGradeAvg(grades, numOfGrades));

cout << endl << endl << endl;

cout << "Please input a letter 'y' if you want to input more students"

<< " any other character will stop the input" << endl;

cin >> moreInput;

}

return 0;

}

//***********************************************************************

This function finds the average of the

numbers stored in an array.

//***********************************************************************

float findGradeAvg(GradeType array, int numGrades)

{

float average = 0;

for (int counter = 0; counter <= numGrades; counter++){

average += array[counter];

}

average = average / numGrades;

  

}

//***********************************************************************

This function finds the letter grade for the number

passed to it by the calling function

//***********************************************************************

char findLetterGrade(float numGrade)

{

if (numGrade <= 100 && numGrade >= 90)

return 'A';

else if (numGrade <= 89&& numGrade >= 80)

return 'B';

else if (numGrade <= 79&& numGrade >= 70)

return 'C';

else if (numGrade <= 69&& numGrade >= 60)

return 'D';

else return 'F';

  

}

here the data returned: the grade (based on a 10 point spread) based on the

number passed to the function.

Comments provided will help you understand the code.

Hope this will help.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote