Question

C++ Programming: Using Conditions Hello, can anyone create a C++ program that will allow me to...

C++ Programming: Using Conditions

Hello, can anyone create a C++ program that will allow me to ask the user to supply the current total and the quantity of the hardware purchased. This program should calculate the grand total based on the number of units purchased as shown in the chart below:

Amount of Hardware

Discount Received

10-19

20%

20-49

30%

50-99

40%

100 or more

50%

Also, make sure to certify what happens when the user enter 0 or less items!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ Code :

#include <iostream>
using namespace std;
int main()
{
float total,quantity;
float discount=0,grandtotal;
cout<<"Enter current total : "; //entering total
cin>>total;
cout<<"Enter quantity : "; //entering grand total
cin>>quantity;
  
if(quantity<=0)
cout<<"Quantity cannot be negative or Zero "; //prints if the quantity is<=0
else
{
if(quantity>=10 && quantity<=19)
discount=20;
else if(quantity>=20 && quantity<=49)
discount=30;
else if(quantity>=50 && quantity<=99)
discount=40;
else if(quantity>=100)
discount=50;
  
grandtotal=total-((total*discount)/100); //calculates grand total based on the discount
cout<<"Grand total is :"<<grandtotal;
}
return 0;
}

8 12 14 #include <iostream> 2 using namespace std; 3 int main() 4-{ 5 float total, quantity; 6 float discount=0,grand total;


Output :

Enter current total : 100 Enter quantity : 10 Grand total is : 80

Please comment if you face any difficulty

Add a comment
Know the answer?
Add Answer to:
C++ Programming: Using Conditions Hello, can anyone create a C++ program that will allow me to...
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
  • NOTE: All C++ programs that you write must have comments at the top with the program...

    NOTE: All C++ programs that you write must have comments at the top with the program name, your name, and the pseudocode describing what the program will do. 1. Create a new program that will calculate the total cost for software purchased from a store. Each software package costs $99.00, but discounts are given on the total cost, based on the number of packages purchased. a. Ask the user for the number of packages they want to buy b. Calculate...

  • Hello, Is anyone able to do the C++ programming for the below in visual studio. The...

    Hello, Is anyone able to do the C++ programming for the below in visual studio. The code online is giving me errors. It just needs to be very very simple as I am a beginner. I have not learned functions yet but can include the math library. I have only 1 hour. thanks Write a program that reads from the user a positive integer (in a decimal representation), and prints its binary (base 2) representation. Your program should interact with...

  • I need this code in C programming. Can anyone pls help me in this? Project 8,...

    I need this code in C programming. Can anyone pls help me in this? Project 8, Program Design A hotel owner would like to maintain a list of laundry service requests by the guests. Each request was stored with the room number, the guest's first name, last name, and number of items. The program laundry_list.ccontains the struct request declaration, function prototypes, and the main function. Complete the function definitions so it uses a dynamically allocated linked list to store the...

  • Python 3. Can anyone please help me with these two homework using Python 3. Thanks in...

    Python 3. Can anyone please help me with these two homework using Python 3. Thanks in advance 8. Tip, Tax, and Total Write a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15 percent tip and 7 percent sales tax. Display each of these amounts and the total. 9. Celsius to Fahrenheit Temperature Converter Write...

  • Q4 130 Quantity discounts are given according to the following table O points) A software company...

    Q4 130 Quantity discounts are given according to the following table O points) A software company sells one software package regularly for 99 QR Quantity Discount 20% 10-19 20-49 50-99 |00 or more 40% 50% write ρ program that asks for the number of items sold, and computes the total cost of the purchase. if the user enters an invalid number of items, the program displays invalid Purchasel" message. Sample output Enter number of items: 25 Total cost is 1732.5...

  • programming language c++ its a project if anyone can help me it's will be appreciated thnk...

    programming language c++ its a project if anyone can help me it's will be appreciated thnk u. u have to create a code based on the information im giving u you can do it in 1 or 2 day i can wait 1:26 #WW 2.53% Example: A user starts with 1000 points. Game #1 - user chooses to risk 200 points. User wins game (beats the dealer). User now has 1200 points. Game #2 - user chooses to risk 500...

  • I need help building code in python for this: Create a program that: Creates a sales...

    I need help building code in python for this: Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file...

  • C++ programming Phone Book Create a class that can be used for a Phone Book. The...

    C++ programming Phone Book Create a class that can be used for a Phone Book. The class should have attributes for the name and phone number. The constructor should accept a name and a phone number. You should have methods that allow the name to be retrieved, the phone number to be retrieved, and one to allow the phone number to be changed. Create a toString() method to allow the name and number to be printed. Write a program that...

  • Using C#, write a program. You are a coffee and tea shop. You will allow customers...

    Using C#, write a program. You are a coffee and tea shop. You will allow customers to enter their orders. You sell coffee and tea in three sizes, small coffee for $1.00, medium for $1.20, and large for $1.40. Tea is $1.20, $1.40, and $1.60. You will let ask the user what they want, size, ask if they want to order anything else, continue taking their order. At the end show them how much they owe. If they order more...

  • Can someone help me with a c++ program Create a program that displays a measurement in...

    Can someone help me with a c++ program Create a program that displays a measurement in either inches or centimeters. If necessary, create a new project named Introductory 18 Project, and save it in the Cpp8\Chap09 folder. The program should allow the user the choice of converting a measurement from inches to centimeters or vice versa. Use two program-defined functions: one for each different conversion type. Enter your C++ instructions into a source file named Introductory 18.cpp Also enter appropriate...

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