Question

This is done in c programming and i have the code for the programs that it wants at the bottom i jut dont know how to call the functions

Progs 2,3, 4 ASSIGNMENT Write menu-driven program to allow the user to select and run program from one of the first 3 ohapterProgs 2, 3, 4 Meniu 2-Tip, Tax, Total Minutes, Hours, Days 4- Calories Burned Enter a choice (-1 to quit): 4 You burn 3.9 cal

Program 2:Tip,Tax,Total

int main(void)
{
   // Constant and Variable Declarations

   double costTotal= 0;
   double taxTotal = 0;
   double totalBill = 0;
   double tipPercent = 0;

   // *** Your program goes here ***
   printf("Enter amount of the bill: $");
   scanf("%lf", &costTotal);
   printf("\n");

   // *** processing ***
   taxTotal = 0.07 * costTotal;
   totalBill = costTotal + taxTotal;
   tipPercent = 0.15 * totalBill;
   totalBill = taxTotal + costTotal + tipPercent;


   // *** output ***

   printf("Based on a bill of $%.2lf, The calculated amounts are:\n", costTotal);
   printf("Tip = $%.2lf\n", tipPercent);
   printf("Tax = $%.2lf\n", taxTotal);
   printf("Total = $%.2lf\n", totalBill);
   printf("\n");


   return 0;
} // end main()

Program 3: Minutes,hours,days

int main(void)
{
   // Constant and Variable Declarations
   int numSeconds = 0;
   double numMins = 0.0;
   double numHours = 0.0;
   double numDays = 0.0;
   int const NUMSECMIN = 60;
   int const NUMSECHOUR = 3600;
   int const NUMSECDAY = 86400;

   // *** Your program goes here ***
   printf("Enter the number of seconds: ");
   scanf("%d", &numSeconds);
   printf("\n");
  
   // ***processing***
   numMins = numSeconds / NUMSECMIN;
   numHours = numSeconds / NUMSECHOUR;
   numDays = numSeconds / NUMSECDAY;

   if (numSeconds >= 1) {
       printf("The number of seconds you entered, %d, is %.2lf minutes.\n", numSeconds, numMins);
      
   }
   else {
       printf("The number of seconds entered must be greater than 0.\n");
   }
       if (numSeconds >= NUMSECHOUR) {
       printf("The number of seconds you entered, %d, is %.2lf hours.\n", numSeconds, numHours);
      
       }
       if (numSeconds >= NUMSECDAY) {
           printf("The number of seconds you entered, %d, is %.2lf days.\n", numSeconds, numDays);
      
       }
       printf("\n");

   return 0;
} // end main()

Programm 4: Calories Burned

int main(void)
{
   // Constant and Variable Declarations
   const double CALORIES_MIN = 3.9;
   int loopStart = 10;
   int loopEnd = 30;
   double whileLoop = 19.5;
   int loopTwostart = 10;
   int loopTwoend = 30;
   double doWhileloop = 19.5;
   int loopForstart = 10;
   int loopForEnd = 30;
   double loopFor = 19.5;

   // *** Your program goes here ***
   printf("You burn 3.90 calories every minute you run.\n");//printing out the starting prompt no input
   printf("This shows how many calories you burn if you ran for 'x' minutes.\n");
  
   printf("\tMinutes Calories\n");
   printf("\t------- --------\n");
   printf("Using a while loop\n");
   while (loopStart <= loopEnd) {
       whileLoop = whileLoop + 19.5;//incrimenting the min loop varaiable
       printf("\t %d\t%.2lf\n", loopStart, whileLoop);
       loopStart = loopStart + 5;// incrimenting the caloires
   }
   printf("\n");// new line
   printf("Using a do-while loop\n");
   do {
       doWhileloop = doWhileloop + 19.5;//incrimenting the min loop varaiable
       printf("\t %d\t%.2lf\n", loopTwostart, doWhileloop);
       loopTwostart = loopTwostart + 5;// incrimenting the caloires
   } while (loopTwostart <= loopTwoend);// this is the condition
   printf("\n");
   printf("Using a for loop\n");
  
   for (int i = loopForstart; i <= loopForEnd; i = i + 5) {
       loopFor = loopFor + 19.5;
       printf("\t %d\t%.2lf\n", loopForstart, loopFor);
       loopForstart = loopForstart + 5;
   }
       printf("\n");

   return 0;
} // end main()

Progs 2,3, 4 ASSIGNMENT Write menu-driven program to allow the user to select and run program from one of the first 3 ohapters of CPT 234. Create a function to display a menu of choices, and have the function return the choice made by the user. Also create a void function to take the menu choice and run the desired program. Invoke the menu function, and pass the menu choice to the 2nd function. Put the above functions in a loop so that the menu will continue to display (and the program will continue to run) until the user selects-1 (or any negative value). When the program ends, display Good bye! Create 3 other functions for the 3 chapter programs - TipTaxTotal (Chapter 2). MinutesHoursDays (Chapter 3), and CaloiesBurned (Chapter 4). Each of these functions will accept no arguments and will also return nothing. Follow the prior program instruations for each of these programs The Chapter 3 program will use a decision to validate that the number of seconds is greater than 0, and if not the Chapter 3 program will display a message. end, and return to the menu Menu choices that are positive numbers (other than 2, 3, or 4) will do nothing and return to the menu. There are 2 blank line before the menu is re-displayed. Example Run #1 bold type is what is entered by the user) Progs 2, 3, 4 Menu 2- Tip, Tax, Total 3Minutes, Hours, Days 4 - Calories Burned Enter a choice (1 to quit) 2 Enter the amount of the bi1i: $50.00 Based on a bill of $50.00, the calculated amounts are: Tip-$7.50 Tax$3.50 Total$61.00 Progs 2, 3, 4 Menu 2- Tip, Tax, Total 3Minutes, Hours, Days 4 - Calories Burned Enter a choice (1 to quit 3 Enter the number of second 40000 The number of second3 you entered, 40000, is 666.67 minutes. The number of seconds you entered, 40000, 13 11.11 hours
Progs 2, 3, 4 Meniu 2-Tip, Tax, Total Minutes, Hours, Days 4- Calories Burned Enter a choice (-1 to quit): 4 You burn 3.9 calories every rinute you run This shows how many calories you burn if you ran for 'x' minutes Minutes Calories Using a while loop 10 15 20 25 30 39.00 58.50 78.00 97.50 117.00 Using a do-while Loop 10 15 20 25 30 39.00 59.50 78.00 97.50 117.00 Using a for loop 10 15 20 39.00 58.50 78.00 97.50 117.00 30 Progs 2, 3, 4 Menu 2 -Tip, Tax, Total Minutes, Hours, Days 4 - Calories Burned Enter a choice (1 to quit): 5 Progs 2, 3, 4 Menu 2 Tip, Tax, Total 3 - Minutes, Hours, Days 4 - Calories Burned Enter a choice (i to quit): -1 Good bye! The example runs show EXACTLY how your program input and output will look
0 0
Add a comment Improve this question Transcribed image text
Answer #1

void tip_tax_total()
{
   // Constant and Variable Declarations

   double costTotal= 0;
   double taxTotal = 0;
   double totalBill = 0;
   double tipPercent = 0;

   // *** Your program goes here ***
   printf("Enter amount of the bill: $");
   scanf("%lf", &costTotal);
   printf("\n");

   // *** processing ***
   taxTotal = 0.07 * costTotal;
   totalBill = costTotal + taxTotal;
   tipPercent = 0.15 * totalBill;
   totalBill = taxTotal + costTotal + tipPercent;


   // *** output ***

   printf("Based on a bill of $%.2lf, The calculated amounts are:\n", costTotal);
   printf("Tip = $%.2lf\n", tipPercent);
   printf("Tax = $%.2lf\n", taxTotal);
   printf("Total = $%.2lf\n", totalBill);
   printf("\n");


  }

void minutes_hours_delays()
{
   // Constant and Variable Declarations
   int numSeconds = 0;
   double numMins = 0.0;
   double numHours = 0.0;
   double numDays = 0.0;
   int const NUMSECMIN = 60;
   int const NUMSECHOUR = 3600;
   int const NUMSECDAY = 86400;

   // *** Your program goes here ***
   printf("Enter the number of seconds: ");
   scanf("%d", &numSeconds);
   printf("\n");
  
   // ***processing***
   numMins = numSeconds / NUMSECMIN;
   numHours = numSeconds / NUMSECHOUR;
   numDays = numSeconds / NUMSECDAY;

   if (numSeconds >= 1) {
       printf("The number of seconds you entered, %d, is %.2lf minutes.\n", numSeconds, numMins);
      
   }
   else {
       printf("The number of seconds entered must be greater than 0.\n");
   }
       if (numSeconds >= NUMSECHOUR) {
       printf("The number of seconds you entered, %d, is %.2lf hours.\n", numSeconds, numHours);
      
       }
       if (numSeconds >= NUMSECDAY) {
           printf("The number of seconds you entered, %d, is %.2lf days.\n", numSeconds, numDays);
      
       }
       printf("\n");

   }

void Calories_burned()
{
   // Constant and Variable Declarations
   const double CALORIES_MIN = 3.9;
   int loopStart = 10;
   int loopEnd = 30;
   double whileLoop = 19.5;
   int loopTwostart = 10;
   int loopTwoend = 30;
   double doWhileloop = 19.5;
   int loopForstart = 10;
   int loopForEnd = 30;
   double loopFor = 19.5;

   // *** Your program goes here ***
   printf("You burn 3.90 calories every minute you run.\n");//printing out the starting prompt no input
   printf("This shows how many calories you burn if you ran for 'x' minutes.\n");
  
   printf("\tMinutes Calories\n");
   printf("\t------- --------\n");
   printf("Using a while loop\n");
   while (loopStart <= loopEnd) {
       whileLoop = whileLoop + 19.5;//incrimenting the min loop varaiable
       printf("\t %d\t%.2lf\n", loopStart, whileLoop);
       loopStart = loopStart + 5;// incrimenting the caloires
   }
   printf("\n");// new line
   printf("Using a do-while loop\n");
   do {
       doWhileloop = doWhileloop + 19.5;//incrimenting the min loop varaiable
       printf("\t %d\t%.2lf\n", loopTwostart, doWhileloop);
       loopTwostart = loopTwostart + 5;// incrimenting the caloires
   } while (loopTwostart <= loopTwoend);// this is the condition
   printf("\n");
   printf("Using a for loop\n");
  
   for (int i = loopForstart; i <= loopForEnd; i = i + 5) {
       loopFor = loopFor + 19.5;
       printf("\t %d\t%.2lf\n", loopForstart, loopFor);
       loopForstart = loopForstart + 5;
   }
       printf("\n");

  
}

so then you can make a common main for all these functions and call these functions as below

int main(){

tip_tax_total();

minutes_hours_delays();

Calories_burned();

return 0;

}

Or you can even provide arguments to the above functions and then pass all the entered by the user and hence call the function alongwith passing those arguments .

Add a comment
Know the answer?
Add Answer to:
This is done in c programming and i have the code for the programs that it wants at the bottom i ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ HELP I need help with this program. I have done and compiled this program in...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. I am using printf and scanf. Instead of printf and scanf use cin and cout to make the program run. after this please split this program in three files 1. bill.h = contains the class program with methods and variables eg of class file class bill { } 2. bill.cpp = contains the functions from class...

  • Plz give me correct code and screen shots for this question by using SASM !!!!!!!! Implement...

    Plz give me correct code and screen shots for this question by using SASM !!!!!!!! Implement the following working C++ program in assembler. Submit assembler code and screen shot. #include <iostream> #include <iomanip> using namespace std; // This menu-driven Health Club membership program carries out the // appropriate actions based on the menu choice entered. A do-while loop // allows the program to repeat until the user selects menu choice 4. int main() { // Constants for membership rates const...

  • Write this program using C++ , (Rock, Paper, Scissors Game – Page 373) This programming assignment...

    Write this program using C++ , (Rock, Paper, Scissors Game – Page 373) This programming assignment is from the textbook with some slight modifications and clarifications. Here is what I am going to except from you. Your program should include at least the following functions: getComputerGuess(): this function should return a random value generated by the computer using rand function (read more about random numbers in Chapter 3 pages 126 – 128). getUsersChoice(): this function will ask the user to...

  • C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...

  • I need MIPS code for this program Translate the following C++ program to MIPS assembly program...

    I need MIPS code for this program Translate the following C++ program to MIPS assembly program (Please explain each instruction of your code by a comment and submit a .asm file) // Example program #include <iostream> #include <string> using namespace std; int main() { const int ADULT_CHOICE= 1, CHILD_CHOICE= 2, SENIOR_CHOICE= 3, QUIT_CHOICE= 4, ADULT = 250, CHILD = 200, SENIOR = 350; int choice, months; int charges = 0; do { cout <<"\n\t\tHealth Club Membership Menu\n\n" <<"1. Standard Adult...

  • CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c...

    CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a...

  • So I have a question in regards to my program. I'm learning to program in C...

    So I have a question in regards to my program. I'm learning to program in C and I was curious about the use of functions. We don't get into them in this class but I wanted to see how they work. Here is my program and I would like to create a function for each of my menu options. I created a function to display and read the menu and the option that is entered, but I would like to...

  • Please do the following programs in C++ complier. Do all the programs. I will give upvote...

    Please do the following programs in C++ complier. Do all the programs. I will give upvote straight away. 1) Write a program that uses a menu. Use a while loop in your code. Ensure your menu has an option to quit the program. 2)Write a program that creates an int array of size 10, then uses a for-loop to populate the array with numbers from your favorite number pattern. 3) Write a function that accepts an array as input then...

  • I'm having trouble understanding pointers in my c programming class. I posted the pointer assignment below....

    I'm having trouble understanding pointers in my c programming class. I posted the pointer assignment below. If you could leave comments pointing out where pointers are used it would be much appreciated! ----------------------------------------------------------------------------------------------------------------------------------- Write a complete C program for an automatic teller machine that dispenses money. The user should enter the amount desired (a multiple of 10 dollars) and the machine dispenses this amount using the least number of bills. The bills dispenses are 50s, 20s, and 10s. Write a...

  • Hello, I have my piece of C programming code and I have a pointer initialized to...

    Hello, I have my piece of C programming code and I have a pointer initialized to point to my array and I need help to display the contents of my array using a while loop or do-while loop. The stop condition should be when the pointer reaches '\0'. The code is below: #include <stdio.h> int main () {    char array[80]; printf("Enter a string: "); scanf("%[^\n]", &array); printf("%s\n", array); char * p;    p = array;         }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT