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

C++ PROGRAM Create a program that lets Dave choose between a tip calculator, sto

ID: 3789072 • Letter: C

Question

C++ PROGRAM

Create a program that lets Dave choose between a tip calculator, stopwatch or a gas mileage calculator. Your main function should act as the menu for choosing a function. You should have 3 additional functions. One for each function. After Dave uses a function he should be asked if he would like to use the same function, choose a new one or end the program.

However, this will be free trial software. After Dave tries all three functions or uses any function 3 times the program should remind Dave that this is a free trial. The program should then end without Dave's consent.

Here's what I have so far:

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

int main()
{
int people;
double bill, tiptotal, total, tip;
char ans;

cout << "Welcome to tip Calculator ";
cout << "Enter bill amount: " << "$";
cin >> bill;
cout << "How many people will be splitting the bill? ";
cin >> people;
cout << "Enter Tip: " << "%";
cin >> tip;

tiptotal = (bill * (tip / 100)) / people;
total = ((tiptotal*people) + bill) / people;

cout << " Tip per person at " << tip << "% is $" << tiptotal << endl << "Each person will pay $"<< total << endl;

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

cout << "Welcome to Stopwatch. ";

int start_s=clock();

  // the code you wish to time goes here int stop_s=clock();

cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;

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

cout << "Welcome to gas mileage calculator. ";

return 0;

}

I have no idea how to finish the stopwatch and how to make my main function act as the menu. Please Help and please NO FANCY CODE.

remind: However, this will be free trial software. After Dave tries all three functions or uses any function 3 times the program should remind Dave that this is a free trial. The program should then end without Dave's consent.

If you have any question ask me. Thanks.

Explanation / Answer

C++ program

#include<iostream>
#include<ctime>

using namespace std;
void calculator(void); //function for Tip calculation
void stopwatch(void); // function for stopwatch
void milage(void);// function for Gas mileage calculator
int main()
{
   int count = 0,ext = 1,opt;
   char S;
   while(ext) // loop will work til ext = 0
   {
      if(count == 3){ cout<< "This is a free trial! Press y to continue.. "; count =0; cin >> S;}// informing "This is a free trial" after each 3 tirals
      cout << " Select your program from the manu" << endl;// the manu
      cout <<"1. Tip calculator 2. Stopwatch 3. Gas mileage calculator 4. Exit"<< endl;
      cout <<"Enter your option: ";
      cin >> opt; // select the option
      switch(opt)
      {
         case 1:
                 calculator();
                 break;
         case 2:
                 stopwatch();
                 break;
         case 3:
                 milage();
                 break;
         case 4:
                 ext = 0;
      }
      count++;
   }
   return 0;
}
// function same as you given
void calculator()
{
   int people;
   double bill, tiptotal, total, tip;
   cout << "Welcome to tip Calculator ";
   cout << "Enter bill amount: " << "$";
   cin >> bill;
   cout << "How many people will be splitting the bill? ";
   cin >> people;
   cout << "Enter Tip: " << "%";
   cin >> tip;
   tiptotal = (bill * (tip / 100)) / people;
   total = ((tiptotal*people) + bill) / people;
   cout << " Tip per person at " << tip << "%" << " is $ " << tiptotal << endl << "Each person will pay $"<< total << endl;
}

void stopwatch()
{
   int stop_s,start_s=clock();
   char temp;
   cout << "Welcome to Stopwatch. ";
   cout <<"Stopwatch Started... Press any key to stop ";// white til some key press occures
   cin >> temp;
   stop_s = clock();
   cout << "time: " << (stop_s-start_s)/double(CLOCKS_PER_SEC)*1000 << endl;
}
// same as you given
void milage()
{
   double capacity, miles, average;
   cout << "Welcome to gas mileage calculator. ";
   cout << "Enter the number of size of the tank (gallons): ";
   cin >> capacity;
   cout << "Enter the number of miles per tank of gas: ";
   cin >> miles;
   average = miles/capacity;
   cout << "The car's MPG is: " << average << endl << endl;
}

OUTPUT

maths@maths-HP-Z440-Workstation:~/Chegg$ g++ threeFunctionsmanu.cpp
maths@maths-HP-Z440-Workstation:~/Chegg$ ./a.out


Select your program from the manu
1. Tip calculator
2. Stopwatch
3. Gas mileage calculator
4. Exit
Enter your option: 1
Welcome to tip Calculator

Enter bill amount: $100
How many people will be splitting the bill? 1
Enter Tip: %5

Tip per person at 5% is $ 5
Each person will pay $105


Select your program from the manu
1. Tip calculator
2. Stopwatch
3. Gas mileage calculator
4. Exit
Enter your option: 2
Welcome to Stopwatch.

Stopwatch Started...
Press any key to stop
k
time: 0.067


Select your program from the manu
1. Tip calculator
2. Stopwatch
3. Gas mileage calculator
4. Exit
Enter your option: 3
Welcome to gas mileage calculator.

Enter the number of size of the tank (gallons): 1
Enter the number of miles per tank of gas: 100
The car's MPG is: 100

This is a free trial! Press y to continue..

y


Select your program from the manu
1. Tip calculator
2. Stopwatch
3. Gas mileage calculator
4. Exit
Enter your option: 4
maths@maths-HP-Z440-Workstation:~/Chegg$

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