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...

  • 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>...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A...

    NEED CODE HELPS WITH C PROGRAMMING. ISSUES EXPLAINED IN BOLD. COMPARING TWO LETTERS AND CALLING A FUNCTION.   Problem are explained in bold #include <stdio.h> #include <string.h> #include <stdlib.h> #define pi 3.1415 void Area (double n); void VolSphere (double n); void Circumference (double n); void AllCalc (); // i dont know if the declaration of the function is correct AllCalc = AllCalculations //function main begins program execution int main (void) { puts("-Calculating Circle Circumference, Circle Area or Sphere Volume-\n"); void (*f[4])...

  • 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...

  • C++ Can someone please help with this code... even when the players number isnt a winning number the program always says the player wins: #include <stdio.h> #include <time.h> //main functi...

    C++ Can someone please help with this code... even when the players number isnt a winning number the program always says the player wins: #include <stdio.h> #include <time.h> //main function int main() {    //seeding a random number    srand(time(0));    //define the arrays for the wagered, winning amount, percent amount    double amounts[7] = { 1, 5, 10, 20, 50, 100, 1000 };    double payoff[7] = { 100, 500, 1000, 2000, 5000, 10000, 100000 };    double percent[7] = { 0.01, 0.05, 1, 2,...

  • Objectives: - Practice designing/implementing algorithms - Practice use of functions Code and document the following functions...

    Objectives: - Practice designing/implementing algorithms - Practice use of functions Code and document the following functions using NON-RECURSIVE ITERATION only. Test the functions by calling them from a simple interactive main() function using a menu, with different values used to select the choice of function. Overall, you should have one C program (call it Lab1.c) containing one main() function and 5 other functions, where the functions are called based on an interactive user menu. The program should contain a loop...

  • Objectives: - Practice designing/implementing algorithms - Practice use of functions Code and document the following functions...

    Objectives: - Practice designing/implementing algorithms - Practice use of functions Code and document the following functions using NON-RECURSIVE ITERATION only. Test the functions by calling them from a simple interactive main() function using a menu, with different values used to select the choice of function. Overall, you should have one C program (call it Lab1.c) containing one main() function and 5 other functions, where the functions are called based on an interactive user menu. The program should contain a loop...

  • 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...

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
ADVERTISEMENT