[Solved] SOLVED: Assignment #5

30 $

File Name: SOLVED:_Assignment_#5.zip
File Size: 197.82 KB

SKU: [Solved] SOLVED: Assignment #5 Category: Tag:

Or Upload Your Assignment Here:


Program A: Pizza Ordering (ordering.c):Your friend is looking to open up a fastfood pizza restaurant. He’s got everything ready so far, but last minute, he realized that no one working there knows how to calculate order totals. He’s asked you to write a program that prompts users to enter the menu options they want (as many as they want), then outputs the total order cost with tax. Refer to the sample below for the menu item names and prices. An input of 0 (zero) should be the case for ending the loop and outputting the total with tax.To simplify the process, your program should store sales tax using a constant:#define SALES_TAX .06Your program should have (and use) the following functions (written by you):// Precondition:option will be a valid option number for the menu.// Postcondition:Returns the cost of this item.double getPrice(int option);// Precondition:option will be a valid option number for the menu.// Postcondition:Outputs the name of this item.void printOptionName(int option);// Precondition:None// Postcondition:Outputs menu options with their numbers and costs.void printMenu();Note: you must use these functions to perform these tasks. The names of the items can only be written in the code for printOptionName , and the prices for the items can only be written in the code for getPrice . The functions printMenu() and main() , as well as any others, must call those first two functions to get these values, they cannot have the menu valuescoded within them.Sample Run (user input in bold and italics):0. (Complete order)1. Small Pizza ****** 5.992. Medium Pizza ****** 6.993. Large Pizza ****** 7.994. Wings ****** 10.505. Drink ****** 3.502Added Medium Pizza0. (Complete order)1. Small Pizza ****** 5.992. Medium Pizza ****** 6.993. Large Pizza ****** 7.994. Wings ****** 10.505. Drink ****** 3.505Added Drink0. (Complete order)1. Small Pizza ****** 5.992. Medium Pizza ****** 6.993. Large Pizza ****** 7.994. Wings ****** 10.505. Drink ****** 3.500Total: $11.12Program B: Twin Prime Tester (twinprime.c):Travis is easily amused by various math patterns. This week, his favorite pattern is what isknown as twin primes. Twin primes are a pair of prime numbers that are exactly two apart. Forexample, 11 and 13 are twin primes, since they are both prime and are exactly 2 apart.(Remember, a prime number is a number not evenly divisible by anything except 1 and itself.)To entertain Travis for the week, you would like to write a program that will determine whether a given number is a twin prime with the prime number that comes next after it. Additionally, Travis might try to mess with you by entering a number that is not prime, so the first number you use in the pair should be the next highest prime number if the entered one is not prime.(Note the number entered will always be greater than 1.)Your program should have (and use) the following functions (written by you):// Precondition:value will be an integer greater than 1.// Postcondition:Returns true (1) if value is prime, or// false (0) otherwise.int isPrime(int value);// Precondition:current will be a positive integer greater than 1.// Postcondition:Returns the next prime number greater than or// equal to current.int nextPrime(int current);Sample Run (User input in bold and italics):55 and 7 are twin primes.Sample Run (User input in bold and italics):1011 and 13 are twin primes.Sample Run (User input in bold and italics):3637 and 41 are not twin primes.Sample Run (User input in bold and italics):22 and 3 are not twin primes.

Program C: Power Comparison (powcompare.c):Stephen is practicing exponentiation. So he’s decided to practice comparing one number raised to a power with another number raised to another power. But sometimes he messes up, and they aren’t equal. When this happens, give him a chance to reenter the second set of numbers until they do equal.The first example is 2 4 = 4 2 = 16.Your program should have (and use) the following function (written by you):// Precondition:base and pow will be nonnegative integers.// Postcondition:Returns base raised to the power of pow.int power(int base, int pow);Sample Run (User input in bold and italics):Enter baseA and powerA2 4Enter baseB and powerB4 22^4 = 4^2 = 16Sample Run (User input in bold and italics):Enter baseA and powerA5 6Enter baseB and powerB10 3Not equal.Enter baseB and powerB25 35^6 = 25^3 = 15625Sample Run (User input in bold and italics):Enter baseA and powerA11 2Enter baseB and powerB121 111^2 = 121^1 = 121Deliverables:Please submit three separate .c files for your solutions to these problems via WebCourses bythe designated due date:Program A: ordering.cProgram B: twinprime.cProgram C: powcompare.c

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] SOLVED: Assignment #5
30 $