Question

In: Computer Science

Hello, this question relates to a class I am taking called introduction to C++. I have...

Hello, this question relates to a class I am taking called introduction to C++. I have no experience writing programs and outside of learning out of a textbook, and studying on my own, have little understanding of logic. I have been assigned a problem that requires me to write a program for a Grocery Bill, where the consumer inputs the price for 5 items, that the program calculates the total with a 6% sales tax. I really am not sure where to start for this exercise. Here is the assignment word for word:

"For this assignment, write a program that calculates a grocery bill. The program should output “Joe’s Market” as the title. The program should prompt the user to enter the price for five products of your choosing. The program should calculate the total price of the groceries, add 6% sales tax to the groceries, and display the total price including sales tax. Be sure to include comments throughout your code where appropriate."

Solutions

Expert Solution

Bill.cpp

#include<iostream>
using namespace std;
// main function
int main()
{
   // variables declaration
   double keyboard,mouse,monitor,hardDisk,panDrive,totalPrice,netPrice,tax;
   cout<<"*** Welcome To Joe's Market ***"<<endl<<endl;
   // accept prices for 5 product from user
   cout<<"Enter the price of Keyboard: ";
   cin>>keyboard;
   cout<<"Enter the price of Mouse: ";
   cin>>mouse;
   cout<<"Enter the price of Monitor: ";
   cin>>monitor;
   cout<<"Enter the price of Hard Disk: ";
   cin>>hardDisk;
   cout<<"Enter the price of Pan Drive: ";
   cin>>panDrive;
   // calculate total price of 5 products
   totalPrice=keyboard+monitor+mouse+panDrive+hardDisk;
   // calculate 6% sales tax
   tax=totalPrice*6/100;
   // calculate net total
   netPrice=totalPrice+tax;
   // print bill
   cout<<endl<<endl<<"**************************************"<<endl;
   cout<<"*** Joe's Market ***"<<endl;
   cout<<"**************************************"<<endl;
   cout<<"Keyboard: "<<keyboard<<endl;
   cout<<"Mouse: "<<mouse<<endl;
   cout<<"Monitor: "<<monitor<<endl;
   cout<<"Hard Disk: "<<hardDisk<<endl;
   cout<<"Pan Drive: "<<panDrive<<endl;
   cout<<"**************************************"<<endl;
   cout<<"Total: "<<totalPrice<<endl;
   cout<<"6% Sales Tax: "<<tax<<endl;
   cout<<"**************************************"<<endl;
   cout<<"Net Total: "<<netPrice<<endl;
   cout<<"**************************************"<<endl;
   return 0;
}

Output


Related Solutions

Hello, I am currently taking software design and analysis class and have a question about those...
Hello, I am currently taking software design and analysis class and have a question about those 3 in cpp, can you please help me? thank you - What is the complexity of pop()? push()? top()? size()? isEmpty()? - Write a C++ implementation of push() in a linked-chain implementation of stack - Write a C++ implementation of pop() in a linked-chain implementation of stack
hello i have question in c++ language Q1: create a class called RightTriangleShape, and it has...
hello i have question in c++ language Q1: create a class called RightTriangleShape, and it has data member called height which initialized to 3 by the constructor of the class. It has also the following function members: Void setHeight() to read, and set the height. Void getHeight() to print the value of height. void leftBottom_RTraingle(), prints shape a void leftTop_RTraingle(), prints shape b. void RightTop_RTraingle(), prints shape c. void RigtBottom_RTraingle(), prints shape d. The functions from 3 to 6 have...
Hi, I am taking stats class and I have one question. I have been struggling with...
Hi, I am taking stats class and I have one question. I have been struggling with it for few hours. To investigate the fluid mechanics of swimming, twenty swimmers each swam a specified distance in a water-filled pool and in a pool where the water was thickened with food grade guar gum to create a syrup-like consistency. Velocity, in meters per second, was recorded and the results are given in a table below. The researchers concluded that swimming in guar...
I have a question about C++ programming Language class. I am confused with these terms and...
I have a question about C++ programming Language class. I am confused with these terms and what they are for. 1. Unix 2. Terminal 3. Git 4. CLOC 5. Linux Please explain each words and what's their jobs for C++. Also, if you know some good sources/websites, could you please provide me a link where I can learn how to use Unix, Terminal, Git, etc.
Hello, I have been trying to answer this question for the last hour and I am...
Hello, I have been trying to answer this question for the last hour and I am still struggling could someone help me? The deadline is in 1hour! Perform an analysis of variance on the following data set. Do this by answering the questions below. Group 1 Group 2 Group 3 82 87 97 91 90 99 93 91 104 94 99 105 94 101 106 95 115 109 99 118 110 101 114 103 117 105 121 106 121 106...
hello, I am having an issue with a question in my highway engineering course. the question...
hello, I am having an issue with a question in my highway engineering course. the question is: An equal tangent sag vertical curve has an initial grade of –2.5%. It is known that the final grade is positive and that the low point is at elevation 82 m and station 1 + 410.000. The PVT of the curve is at elevation 83.5 m and the design speed of the curve is 60 km/h. Determine the station and elevation of the...
Hello, I am trying to write a C++ program that will do the following: Use the...
Hello, I am trying to write a C++ program that will do the following: Use the STL stack container in a program that reads a string, an arithmetic expression to be exact, one character at a time, and determines if the string has balanced parenthesis – that is, for each left parenthesis there is exactly one matching right parenthesis later in the string.                         Use the following strings to test your program. A+ B - C A * B / (C...
Hello, I am working on an assignment but I am unsure of how to solve it....
Hello, I am working on an assignment but I am unsure of how to solve it. Please help me. The assignment details are below. Consider this scenario: Your friend starts a website, nothingbutflags.com, which is not making money. Your friend asks you to help generate more traffic. You ask your friend how much traffic the website had last month? And your friend replies and says only 500 visits. You also ask how many flags did you sell? Your friend replies...
Hello, I am working on an assignment but I am unsure of how to solve it....
Hello, I am working on an assignment but I am unsure of how to solve it. Please help me. The assignment details are below. Consider this scenario: Your friend starts a website, nothingbutflags.com, which is not making money. Your friend asks you to help generate more traffic. You ask your friend how much traffic the website had last month? And your friend replies and says only 500 visits. You also ask how many flags did you sell? Your friend replies...
Hello! Html question. I am trying to add a background to a page. How would i...
Hello! Html question. I am trying to add a background to a page. How would i do this? I have tried using a jpg. The code is posted below. i used the background-image: url function. Any help of different ways to do this would be appreciated! Thank you! CODE: <!DOCTYPE html> <html> <head> <style> ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float: left; } li a { display: block; color: white; text-align:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT