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
View 2 Replies
ADVERTISEMENT
Sep 19, 2014
My code is below:
Total Interest ends up as my last Monthly Payment amount instead of adding up all Interest Paid - What am I doing wrong?
Total Paid isn't calculating correcly either - What am I doing wrong?
I suspect both are very similar problems. I've tried several different calculations, but cannot figure this out.
#include <iostream>
#include <cmath>
using namespace std;
double GetMonthlyIntrest (double OpenBalance,double rate);
bool ContinuePgm();
int main () {
double StartingBalance,rate,amount,OpenBalance,IntPmt,TotalInt=0.0,GrandTotal=0.0;
[code]...
View 3 Replies
View Related
May 17, 2014
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
[Code]....
I know it has to do with the array, and I've tried over and over again to fix my issue and nothing has worked thus far.
View 3 Replies
View Related
Jan 16, 2015
#include<fstream>
#include<iostream>
#include<string>
[Code]...
View 2 Replies
View Related
May 8, 2012
My code in c++ is
#include<iostream.h>
main()
{int a[10],x[5];
a[-7]=15;
x[5]=20;
cout<<x[-5];
}
View 2 Replies
View Related
Mar 6, 2014
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:
#include <iostream>
#include <string>
#include <fstream>
#include <ctime>
#include <cstdlib>
using namespace std;
//function declarations
void init()
[code].....
View 2 Replies
View Related
Apr 24, 2013
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
[Code] .....
View 2 Replies
View Related
Mar 5, 2014
'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()
[Code] ......
View 6 Replies
View Related
Jan 21, 2013
I am looking to create a table somthing like this output below but I am very new to this and my code is abit everywhere.
x sqrt(x) x ^ 2 x ^ 3
========================================
1 1 1 1
2 1.414 4 8
3 1.732 9 27
4 2 16 64
5 2.236 25 125
6 2.449 36 216
7 2.646 49 343
8 2.828 64 512
9 3 81 729
10 3.162 100 1000
========================================
Totals: 55 22.47 385 3025
========================================
This is the code I have I have got it to cal some of the values but numbers our everywhere. I am doing more Trial and error than anything.
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
[Code].....
View 8 Replies
View Related
May 17, 2014
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,
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
[code]....
And here's where the program stops. URL.....
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.
View 10 Replies
View Related
Oct 10, 2014
Why this program won't correctly print the proper totals on screen? See my code and the included screenshot.
Code:
#include <stdio.h>
int main(void) {
int total, first, second;
printf("Enter 2 numbers:
[Code] .....
View 4 Replies
View Related
Oct 10, 2013
how would I write a while() loop that calculates the sum of all prime numbers from 1 - 50.
View 5 Replies
View Related
Jul 24, 2013
This is an assignment which the purpose is to calculate an angle value in form of trigonometric functions. These are the codes that I've wrote so far.
#include <iostream>
#include <cstdlib>
using namespace std;
void menu(double &value) {
system("cls");
cout<<"*****Trigonometry Program*****"<<endl;
[Code] ....
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.
View 2 Replies
View Related
May 15, 2013
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.
#include <iostream>
#include <cmath>
using namespace std;
double original_cost;
double discount;
double tax;
double total;
char answer;
[Code]...
View 2 Replies
View Related
Mar 26, 2014
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.
View 5 Replies
View Related
Dec 17, 2012
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++) {
[code].....
It's not displaying asterisks.
View 1 Replies
View Related
Nov 20, 2013
Corporate Data Sales
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.
Here is my code:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
struct CorpData {
[Code] ....
View 1 Replies
View Related
Jul 1, 2014
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.
View 1 Replies
View Related
Sep 15, 2013
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)
View 10 Replies
View Related
Feb 20, 2014
What I am trying do is this in steps,
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.
for(k=0;k<8;k++) {
remZ=devZ%2;
devZ=(devZ-remZ)/2;
z_bit_array[k]=remZ;
[Code] .....
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.
View 5 Replies
View Related
Oct 22, 2012
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".
View 14 Replies
View Related
Aug 28, 2014
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.
View 2 Replies
View Related
Mar 13, 2014
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.
View 4 Replies
View Related
Feb 20, 2015
I'm trying to create a program that loops "x" number of times, where "x" is going to be a user-input number.
View 2 Replies
View Related
Jan 22, 2014
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.
Code:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <fstream>
#include <string>
using namespace std;
[Code] ....
View 4 Replies
View Related
Oct 25, 2013
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.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int pause(char *);
int getInt(char *);
void whileFunction(int);
void doWhileFunction(int);
void forFunction(int);
[Code] .....
View 12 Replies
View Related