Visual C++ :: Program To Calculate Sales Totals For A General Store - While Loops
Jan 25, 2013
I need coding this project using while loops and cout/cin.. It is suppose to be one while loop for the whole thing and inside of the first while loop is the second while loop for each sale separately.
You have been asked to write a program to calculate sales totals for a general store. Your program will not know how many products each customer will buy, so your program will have to repeat the process until the last product has been entered (use -1 for Product ID to end each sale). After each sale your program must ask if you want to do another sale (Y - continue, N - end program).
At the beginning of the day, the cash drawer has $500 in it. At the end of the program you must display how much money is in the drawer after handling all your sales transactions.
Input
Your program must take the following input:
- Product ID Number (int)
- Quantity for each item purchased (int)
- Cash Received at the end of the sale
Use the following dataset to determine the price and taxability for each item.
First Sale:
Product ID Price Quantity Taxable
101 $65.00 2 Yes
102 $12.50 1 No
103 $24.50 5 No
104 $38.75 4 Yes
105 $17.80 6 Yes
106 $16.50 2 No
107 $42.85 8 Yes
108 $32.99 2 Yes
109 $28.75 1 Yes
110 $51.55 1 No
Second Sale:
Product ID Price Quantity Taxable
102 $12.50 1 No
103 $24.50 1 No
106 $16.50 1 No
107 $42.85 1 Yes
108 $32.99 1 Yes
109 $28.75 1 Yes
Third Sale:
Product ID Price Quantity Taxable
106 $16.50 4 No
107 $42.85 3 Yes
108 $32.99 1 Yes
109 $28.75 5 Yes
110 $51.55 2 No
Calculating Tax
For those items that are taxable, assume a 7.5% sales tax. Be sure to keep a running total of tax for the each sale.
Getting Started
You must use the starter file provided with this assignment.
What to turn in:
- A copy of your source code
- A printout of your program's output
I wrote this program using struct and it works fine, now I want to write it just using arrays and I don't think i can do it. So here is the original code:
Trying to show the Row totals and the Column totals.
#include <stdio.h> int main() { /* start of main */ #define NUMROWS 5 /* establishes NUMROWS as 5 */ #define NUMCOLS 5 /* establishes NUMCOLS as 5 */ int val[NUMROWS][NUMCOLS] = { {23,06,85,22,01}, /* declares array val to have 5 rows and 5 columns */ {07,33,62,17,04},
[Code] ....
I receive this message after building:
1>------ Build started: Project: WA 4 A 1 Christopher Caron, Configuration: Debug Win32 ------ 1> WA 4 A 1 Christopher Caron.cpp 1>c:userschrisdocumentsvisual studio 2010projectswa 4 christopher caronwa 4 christopher caronwa 4 a 1 christopher caron.cpp(21): error C2106: '=' : left operand must be l-value
'm new to programing and I'm trying to get this program to add up a price of coffee to the add on extras such as cinnamon, etc. But once the program runs it doesn't add up the coffee price with the extras and I've been at it for hours...
Code:
#include <iostream> #include <cstdlib> using namespace std; int main()
The code is supposed to display the total and averages of the data as well, but cuts off due to an error in the code. The code should also:
1)Print checks for all employees, one per page, sorted by lastname. The first check number, 100, is to be read from a company data file (see requirement 4). The border of each check is important and should not be omitted.
2)Convert the net pay to a text string for each check printed.
3)Print a reference code on each check. The reference code is obtained by combining the first letter of the lastname with all the consonants remaining after removing all vowels (a,e,i,o,u).
4)Use the same employee data found in assignment 2. Use the following company data, obtained from a text file,
Output I'm expecting: Program to display totals and averages (worked before I turned everything into an array), now exits with error before totals/averages are displayed. Program also writes up a report.txt file that also writes this information into it, as well as using a quicksort to organize the names alphabetically, and print paychecks (all of the #BORDER, #HEADER1-8, #STUB, etc). In that check a reference code is also generated (teacher gave us code, we just had to modify for our final program as seen here)
Flow of the program: Print headings to label all of the input data we will enter soon under the categories as listed in the heading. Initialize all of our totals (in our array) to value of 0. These will be added in a loop "AddAccumulators" which takes our value for the hours, payrate, and taxes from each employee array structure and adds it to the total array. Program will write this information into the report.txt file with the HEADER line for totals, and should be displaying it in that picture. (Same for averages). After all of the data is calculated, the Reference code, Totals, Averages, and individual employee data is taken and put into printing out a Check Header and Stub.
I have completed the codes for the interface part. Before I proceed with the formula for the trigonometric functions, I would like to make sure the program is Error-free, which if there is accidental invalid input from the user, the program would the user to enter another input until it is a valid response.
The only problem I have encountered for this matter was in menu(value)
If I enter an integer, the program will proceed without error. However, If I enter a character, the program will slip into an endless loop which constantly shows this
*****Trigonometry Program***** Please enter an angle value => Is the angle in Degree or Radian? Type D if it is in Degree Type R if it is in Radian Your response=> 0 //my initial input for value
Do you want to continue? Type Y to continue Type any other key to stop Your response =>
Where is the source of the problem? I'm pretty sure it's the loop, but I don't know what to do.
I'm trying to create a program that will take input from a user and calculate it in a do-while loop. The program does the calculation but the answer is wrong. The loop also doesn't work. The purpose of the program is to see how much an item will cost after a discount is taken off and tax is added.
I'm trying to make a c++ program of this but i don't know how to use the bubble sorting.
Write a C++ application that asks the user to enter 10 numbers. The program then stores those numbers in an Array. The program should display the Mean , Median, and Mode.
Mean is the average of the 10 numbers. Median is the average of the 5th and the 6th numbers. (But you have to arrange the numbers in ascending order first using Bubble Sort before calculating the Median.) Mode is the most frequent number among the 10 numbers.
I need to make a bar chart with asterisks that looks like this:
Store 1: ****** Store 2: *** etc.
anyway, right now what I have is:
Code: #include <iostream> #include <iomanip> using namespace std; int main () { const int STORES = 5; int sales[STORES], i; for (i = 0; i < STORES; i++) {
Write a program that uses a structure named CorpData to store the following information on a company division.
Division Name(North, South, East, Or West) First quarter sales Second quarter sales Third quarter sales Fourth quarter sales Total annual sales Average quarter sales
Include a constructor that allows the division name and four quarterly sales amounts to be specified at the time a CorpData variable is created.
The program should create four variables of this structure, each representing one of the following corporate divisions: North, South, East and West. Each variable should be passed in turn to a function that calculates and stores the total annual sales and average sales for that division.
Once this has been done for each division, each variable should be passed in turn to a function that displays the division name, total sales, and average sales.
Build a class named "salesCompany". Save it's name with a string and an array with records which will be filled with values from sales in different cities of the company.
Build the constructor which must get as a parameter the name of the company and a text file which will fill the array. There is an example of the text file format. Every line saves the sold quantity of a product, identified by a code, in a certain city.
CodeCityQuantity 1a63bCity11200 45ab8City2550 #include <iostream> #include <string.h> using namespace std; class salesCompany {
[code].....
what should I add more and how can make it available for the user to enter as an input a text file.
I have to make my program display days 1-30 along side numbers increasing by 5 each day beginning with 6 on the first day. I wrote 2 for loops on separate tabs but now I want to know if its possible to combine them into 1.
For loop 1 int day,; for (day = 1; day <=30; day = day + 1)
For loop 2 int candy; for (int candy = 6; candy <=151; candy = candy +5)
1)I took an integer 2)I try to convert it into binary by storing the remainder by dividing it in 2, in an integer array size of 8(array1) 3)But the digits are in the reverse order, so I reverse them(array 2) 4)When the number is less like 40 or 20 there are no 8 digits/bits 5)So further manipulation of bits i need to pad some other value(say its 2)in the beginning of the array where you will have continuous zero bits.
I want to pad another bit apart from 1 and 0 until you find one. for example say the content of array2 will be 00010111 then i need it to be 22210111.But my method is not working and make the program non responsive.
Here is an imgur link to my current homework. [URL] .....
As you can see on there I have them listed on which ones are supposed to be sentinel and which ones are supposed to be count control loops. This is currently what I have:
Code: #include <iostream> #include <cmath> #include <iomanip> #include <fstream> using namespace std; void main() { int count = 0; int sum = 0;
[Code] ....
This class has me stumped currently and I am having a hard time breezing through the class at my instructors speed. So I don't want to get too far behind.
Right now this program is giving me an error that opens CMD and gives me infinite lines of "0's".
My application requires the user to add sales to images, this is done by displaying the image for the GUI, and then the user would add sales using that images ID which is brought in from the database.
In part this is 2 questions, first question is what is the best way to generate a List for use when adding the sales to the database. The List would need multiple strings for each sale. So for example:
Image 1 (Sale)
- JPG ID - Product ID - Product Quantity
So i'm going to assume i'm best creating a new instance of a custom class for each sale, and then add each instance to a List<Sale>?
public class Sale { public int SaleID { get; set; } public int JpgID { get; set; } public int SaleQty { get; set; } }
Then I need a decent way to update this List with the GUI controls. So maybe get the JPG ID and set name of the Sale Class Instance to the ID, in this way its unique and I can update that instance when it comes to increasing the sale of a product or decreasing it.
Second part comes to the design of the GUI of adding sales, when I made this using HTML/PHP that was easier. It looked something like this:
If I wrote some code to generate that kind of design again in C# it going to require many Controls, wouldn't that be a bit intensive on the system? I just want something which looks great but also functions good.
At some point I'm going to switch to WPF, but I just need to get a working prototype working now which my client can use, and then update it when I have more time as I have got other Web Related projects that need doing, so at the moment WPF is out of the question.
I just started learning the basics of programming. While encountering one of the practice problems in the book by Alex Allain I got a little confused. The question is as follows:
Write a menu program that lets the user select from a list of options, and if the input is not one of the options, reprint the list.
The author assumes you can answer this question only using if statements and/or loops (while, for and do).
This is the code I've written thus far:
Code: #include <iostream> using namespace std; int main() { int option; char reset;
[Code] ....
For some reason, the nested while loop keeps repeating even when you input a valid option (1, 2 or 3). I can't seem to figure out why this happens.
I am trying to use enumeration types in my conditions to make a simple program that calculates area of a square or circle depending on users choice then updates the total area and outputs the total area.
The program builds fine. But it ignores all of my loop conditions and i'm not sure why.
So i have to use these prototype functions to run loops and to pause the program, the only problem is after i select a loop option and enter a number of dots to print in the loop it goes into an infinite loop and why, also when i try using the 4 option to exit it still asks me how many dots i want to print.