Question

In: Computer Science

This assignment is one program demonstrating IF statements and Decisions in C++ format. Program 2 People...

This assignment is one program demonstrating IF statements and Decisions in C++ format.

Program 2 People eating at a restaurant get to eat for free if they are younger than 10, pay full price if they are under 65, get a $3 discount if they are 65 or over. Write a program asking the user for an age of the next customer and the price of the food they ordered. Calculate how much to charge based on the price (set to 0, full price, or with a discount) along with a 15% tip. Then have the program show this amount to the user. Examples: What age is the person 5 What price is the meal 10 The charge for this person is 0 (a second program run) What age is the person 70 What price is the meal 10 The charge for this person is 8.05

Solutions

Expert Solution

Code:

#include<iostream>
using namespace std;
int main()
{
   int age;
   float price,final_charge;
   cout << "What age is the Person : ";
   cin >> age;
   cout << "What price is the Meal : ";
   cin >> price; //taking age and price of the meal from user
   if (age<10) //if age<10 final_charge=0
       {
       final_charge=0;
       }
   else if (age>=10 && age<65) //if age>=10 and age<65 then full price+ 15% tip
       {
       final_charge=price+(price*0.15);
       }
   else if (age>=65) //if age greater than 65 then price+15% tip and 3 dollars discount
       {
       final_charge=price+(price*0.15)-3;
       }
   cout << "The charge for this person is " << final_charge << endl; //finally print the final_charge
   return 0;
}

Code and Output Screenshots:

Note : if you have any queries please post a comment thanks a lot..always available to help you...


Related Solutions

This assignment is 2 programs demonstrating IF statements and Decisions. Program 1 Write a program that...
This assignment is 2 programs demonstrating IF statements and Decisions. Program 1 Write a program that asks a user for a temperature for two storage containers for a spaceship filled with water and oxygen. The program should tell if either is ice and if either is boiling. Numbers to use for your tests The Freezing point of water is 32 and the boiling point is 212. The Freezing point of oxygen is -362 and the boiling point is -306. Program...
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program...
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into BMI is as follows: BMI = Weight *...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice (known as the come-out roll) is equal to 7...
Source code with comments explaining your code in C# Program 2: Buh-RING IT! For this assignment,...
Source code with comments explaining your code in C# Program 2: Buh-RING IT! For this assignment, you’re going to simulate a text-based Role-Playing Game (RPG). Design (pseudocode) and implement (source) for a program that reads in 1) the hero’s Hit Points (HP – or health), 2) the maximum damage the hero does per attack, 3) the monster’s HP and 4) the maximum monster’s damage per attack. When the player attacks, it will pick a random number between 0 and the...
Programming Assignment #2, Processes Write a C program (time_shm.c) that determines the amount of time necessary...
Programming Assignment #2, Processes Write a C program (time_shm.c) that determines the amount of time necessary to run a command from the command line. This program will be run as ./time <command [args...]> and will report the amount of elapsed time to run the specified command. This will involve using fork() and execvp() functions, as well as the gettimeofday() function to determine the elapsed time. It will also require the use of two different IPC mechanisms. The general strategy is...
IN C This assignment is to write a program that will prompt the user to enter...
IN C This assignment is to write a program that will prompt the user to enter a character, e.g., a percent sign (%), and then the number of percent signs (%) they want on a line. Your program should first read a character from the keyboard, excluding whitespaces; and then print a message indicating that the number must be in the range 1 to 79 (including both ends) if the user enters a number outside of that range. Your program...
Please write program in C++ format: Write a program to accept five negative numbers from the...
Please write program in C++ format: Write a program to accept five negative numbers from the user. (1) Find the average of the five numbers and display the answer to the standard output. Keep the answer two decimal points - 5 points (2) Output the numbers in ascending order and display the answer to the standard output. - 5 points
I need specific codes for this C program assignment. Thank you! C program question: Write a...
I need specific codes for this C program assignment. Thank you! C program question: Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and...
Java/Python/C++ Assignment Write a program to implement one round of AES-128 Input is the key and...
Java/Python/C++ Assignment Write a program to implement one round of AES-128 Input is the key and plaintext a. Show the plaintext as a 4x4 matrix b. Show the result after adding RoundKey0 c. Show the result after SubBytes d. Show the result after ShiftRows e. Show the result after MixColumns f. Show the result after first round
C PROGRAMMING – Steganography In this assignment, you will write an C program that includes processing...
C PROGRAMMING – Steganography In this assignment, you will write an C program that includes processing input, using control structures, and bitwise operations. The input for your program will be a text file containing a large amount of English. Your program must extract the “secret message” from the input file. The message is hidden inside the file using the following scheme. The message is hidden in binary notation, as a sequence of 0’s and 1’s. Each block of 8-bits is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT