Question

In: Computer Science

Write a program that provides a customer with the price of his/her choice of a specific...

Write a program that provides a customer with the price of his/her choice of a specific fruit. If the customer selects (1), then the program should print "you select banana and the price is $1.00/lb". If he selects (2) then the program should print "you select orange and the price is $1.50/lb". If he selects (3) then the program should print "you select apple and the price is $1.90/lb". Allow the customer to make a selection, then asking "how many pounds of (apples/oranges/ bananas) would you like? Then ask if they would like to select another fruit (Yes or No) If so, allow them to select another fruit, then how many pounds they would like of the specific fruit. If the user selects (No) when asked if they'd like to select any more fruit, print how many pounds the total of each fruit they selected and their individual totals (example: You've selected 3 pounds of bananas for $3.00) Then the total sum of all of the fruit they've purchased. Example: (Your grand total is: $12.00) Then end with the printed message: "Thank you for selecting the fruits of your choice." PLEASE USE C++ using #include using namespace std

The program should run as followed:

Please select (1) for Bananas which are 1.00/lb

Please select (2) for Oranges which are 1.50/lb

Please select (3) for Apples which are 1.90/lb

(users selects 2)

How many pounds would you like?

(user selected 4)

Would you like to get another fruit? Yes or No

(user selected yes)

Please select (1) for Bananas which are 1.00/lb

Please select (2) for Oranges which are 1.50/lb

Please select (3) for Apples which are 1.90/lb

(users selects 1)

How many pounds would you like?

(user selects 1)

Would you like to get another fruit? Yes or No

(user selected no)

You've purchased:

4 pounds of oranges for $6

1 A pound of Bananas for $1

Your grand total is: $7

Solutions

Expert Solution

#include<iostream>
#include<string.h>
using namespace std;
int main()
{
   int choice;//declaring necessary variables
   float apples=0,bananas=0,oranges=0,weight;
   char exit[3];
   int total_price;
   while(1)
   {
   cout << "Please select (1) for Bananas which are 1.00/lb \nPlease select (2) for Oranges which are 1.50/lb \nPlease select (3) for Apples which are 1.90/lb\n";
   cin >> choice;//reading choice
   cout << "How many pounds would you like?\n";
   cin >>weight;//reading the weight
   if(choice==1)
       bananas+=weight;  
   else if(choice==2)
       oranges+=weight;
   else
       apples+=weight;
   cout << "Would you like to get another fruit? Yes or No\n";
   cin >> exit;
   if (exit[0]=='N' && exit[1]=='o')
       break;//if we enter No
   }
   if(bananas>0)
       cout << bananas << "pounds of bananas for " << bananas <<"$\n";//printing the final bananas cost
   if(oranges>0)
       cout << oranges << "pounds of oranges for " <<oranges*1.5 <<"$\n";//printing the final oranges cost
   if(apples>0)
       cout << apples << "pounds of apples for " << apples*1.90 <<"$\n";//printing the final apples cost
   cout << "Your grand total is: $" <<bananas+(oranges*1.5)+(apples*1.90);//total cost
   return 0;
}

output:


Related Solutions

Write a program that provides a customer with the price of his/her choice of a specific...
Write a program that provides a customer with the price of his/her choice of a specific fruit. If the customer selects 1, then the program should print "you select banana and the price is $1.00/lb". If he selects 2 then the program should print "you select orange and the price is $1.50/lb". If he selects 3 then the program should print "you select apple and the price is $1.90/lb". After the selection is completed you should print a message that...
Write a program in C++ that asks the user for his/her Taxable Income and displays the...
Write a program in C++ that asks the user for his/her Taxable Income and displays the Income Tax owed. Use the following table to calculate the Income Tax: Taxable Income Tax Rate $0 to $9,225 / 10% $9,226 to $37,450 / $922.50 plus 15% of the amount over $9,225 $37,451 to $90,750 / $5,156.25 plus 25% of the amount over $37,450 $90,751 to $189,300 / $18,481.25 plus 28% of the amount over $90,750 $189,301 to $411,500 / $46,075.25 plus 33%...
In C++ Write a program which asks the user his/ her major, stores it in a...
In C++ Write a program which asks the user his/ her major, stores it in a variable called major, then asks What is your GPA? and stores it in a variable called gpa. Next, ask a question based on the answers from the previous two questions. For example: What is your major? computer science What is your gpa? 3.52 computer science is very hard; why do you think you have a gpa of 3.52?
Java - Write a program to calculate a user’s BMI and display his/her weight status. The...
Java - Write a program to calculate a user’s BMI and display his/her weight status. The status is defined as Underweight, Normal, Overweight and obese if BMI is less than 18.5, 25, 30 or otherwise respectively. You need to read weight (in kilogram) and height (in metre) from the user as inputs. The BMI is defined as the ratio of the weight and the square of the height. [10 marks]
Write a Java program that will ask the user for his/her salary (numerical integer salary) and...
Write a Java program that will ask the user for his/her salary (numerical integer salary) and then convert this numerical salary into income class. The following is a guideline to the income class used. The numeric range within parenthesis maps to the preceding class. If the user gave you a number greater than 700,000 or less than 10,000, you should print a message that the input is invalid. In this code, DO NOT USE && OPERATOR. You should use if-else....
In PYTHON OF JUPIDER NOTEBOOK Write a program that prompts the user to enter his/her nationality...
In PYTHON OF JUPIDER NOTEBOOK Write a program that prompts the user to enter his/her nationality (French/french, Italian/italian, or Spanish/spanish). Then ask his/her name using a prompt message in his/her own language (use Google Translate if you need). After getting the name, again greet him/her using a greeting message in his/her own language. If the user is not from any of the above nationalities just use English to prompt for name and to greet the user. Example 1: Nationality? french...
Write a Java program that will ask the user for his/her mark (numerical integer mark) and...
Write a Java program that will ask the user for his/her mark (numerical integer mark) and then convert this numerical mark into letter grades. The following is a guideline to the grading scale used. The numeric range within parenthesis maps to the preceding letter grade. If the user gave you a number greater than 100 or less than 0, you should print a message that the input is invalid. In this code, DO NOT USE && OPERATOR. You should use...
in C++ Requirements: Write a program that creates a new class called Customer. The Customer class...
in C++ Requirements: Write a program that creates a new class called Customer. The Customer class should include the following private data: name - the customer's name, a string. phone - the customer's phone number, a string. email - the customer's email address, a string. In addition, the class should include appropriate accessor and mutator functions to set and get each of these values. Have your program create one Customer objects and assign a name, phone number, and email address...
Overview For this assignment, write a program that will calculate the amount that a customer spends...
Overview For this assignment, write a program that will calculate the amount that a customer spends on tickets at a movie theater. This program will be continued in program 3 so it is important that this program is completed. Basic Program Logic The basic logic for this program is similar to program 1: the user is asked to enter values, a calculation is performed, and the result of the calculation is displayed. For this program, prompt the user for the...
Write a program in a language of your choice to perform a search using the A*...
Write a program in a language of your choice to perform a search using the A* algorithm for the eight puzzle problem, in which numbers may be shifted one space at a time to transform the initial state into the goal state (see p. 103 – 3rd Ed., pp. 105-106 – 2nd Ed. of the text). 2. a) Use the start state-goal state combination given in pp. 103, Figure 3.28 (3rd Ed.), [pp. 105, Figure 4.7 (2rd Ed.)], as (start_1,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT