Question

In: Computer Science

C++ program: ABC Co wants you to develop a C++ program to calculate the total invoice...

C++ program:

ABC Co wants you to develop a C++ program to calculate the total invoice based on the user inputs item price and the quantity of the item purchased, taking into consideration the discount given for each category as follow:

  • Less than 10 Item: No discount
  • Between 10 and 20 items: 10 % off the item price
  • More than 20 items: 20% off the item price.

Your Program should display, the total before discount, how much discount and the total after discount.

  1. Plan for a solution by drawing a flowchart
  2. Write the C++ program to solve the problem above.

Solutions

Expert Solution

input code:

output

code

#include <iostream>
using namespace std;

int main()
{
/*declare the variables*/
int n;
double price,discount,total;
/*take user input*/
cout<<"Enter the price: ";
cin>>price;
cout<<"Enter the quantity: ";cin>>n;
/*find discount*/
if(n<10)
{
discount=0;
}
else if(n<=20)
{
discount=price*n*0.1;
}
else
{
discount=price*n*0.2;
}
/*print output*/
total=price*n;
cout<<"Total before discount : $"<<total<<endl;
cout<<"discount : $"<<discount<<endl;
cout<<"Total after discount : $"<<total-discount;
return 0;
}


Related Solutions

(Write a program in C++) A local instructor wants you to write a program to calculate...
(Write a program in C++) A local instructor wants you to write a program to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60...
Plan for a solution by drawing a flowchart EFG Co wants you to develop a C++...
Plan for a solution by drawing a flowchart EFG Co wants you to develop a C++ program to calculate the total invoice based on the user inputs item price and the quantity of the item purchased, taking into consideration the discount given for each category as follow: Less than 10 Item: No discount Between 10 and 20 items: 10 % off the item price More than 20 items: 20% off the item price.
A local instructor wants you to write a c++ program using arrays to calculate the average...
A local instructor wants you to write a c++ program using arrays to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above...
You will develop a program in C++ that will do a "find and replace" on an...
You will develop a program in C++ that will do a "find and replace" on an input file and write out the updated file with a new name. It will prompt your user for four inputs: The name of the input file. The characters to find in the input file. The replacement (substitute) characters. The name of the output file. It will perform the replacement. Note1: all instances must be replaced not just the first one on a line. Note2:...
You will develop a program in C++ that will do a "find and replace" on an...
You will develop a program in C++ that will do a "find and replace" on an input file and write out the updated file with a new name. It will prompt your user for four inputs: The name of the input file. The characters to find in the input file. The replacement (substitute) characters. The name of the output file. It will perform the replacement. Note1: all instances must be replaced not just the first one on a line. Note2:...
For this assignment you will develop pseudocode and write a C++ program for a simple calculator....
For this assignment you will develop pseudocode and write a C++ program for a simple calculator. You will create both files in Codio. Put your pseudocode and C++ code in the files below. PSEUDOCODE FILE NAME: Calculator.txt C++ SOURCE CODE FILE NAME : Calculator.cpp DESCRIPTION: Write a menu-driven program to perform arithmetic operations and computations on a list of integer input values. Present the user with the following menu. The user will choose a menu option. The program will prompt...
You are using ONLY Programming Language C for this: In this program you will calculate the...
You are using ONLY Programming Language C for this: In this program you will calculate the average of x students’ grades (grades will be stored in an array). Here are some guidelines to follow to help you out: 1. In your program, be sure to ask the user for the number of students that are in the class. The number will help in declaring your array. 2. Use the function to scan the grades of the array. To say another...
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
You are the new accountant for ABC, Co. ABC, Co. is a plumbing supply and installation...
You are the new accountant for ABC, Co. ABC, Co. is a plumbing supply and installation company. Your boss is the President, Mr. Bigg. As the accountant, it is your job to explain to Mr. Bigg the following accounting terms. 1. What is a chart of accounts? 2. What are adjusting journal entries? 3. What is an income statement? Based on your course work of accounting and information systems course (ACC 4310) at your University, what would you recommend to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT