C/C++ :: Quarterly Sales Program Using 2D Arrays?
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
ADVERTISEMENT
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
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
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 1, 2012
how to write a basic tic tac toe program using arrays. I've already done one but without using arrays. As you can see in the code below, there is too much repetitive code which I don't like the look of.
As a beginner, I would like to attempt this myself. I just need to know where to start, what to do, etc... This is where I am stuck.
Here's my code for the tic tac toe program:
Code:
#include <iostream>
using namespace std;
int main()
[Code].....
View 1 Replies
View Related
Sep 24, 2014
This program does everything i want except for one major problem and one small one.
1. The program keeps taking my last entered number and counting it as max and min
2. When I go to end with 0 it adsd the enter number prompt then returns.
#include <iostream>
using namespace std;
int main()
{
[Code].....
View 1 Replies
View Related
Dec 9, 2014
Add a program that declares two arrays of 5 integers each. Provide one function to load one array with random numbers from 1 to 25, another to fill the other array with user supplied values, and a third function to print an array. The main function should declare the arrays and use the functions to fill each array and print them both.
The code i have so far is
#include <cstdlib>
#include <iostream>
using namespace std;
void printaaray(int printarray1[], int printarray2);
[Code]....
View 2 Replies
View Related
Apr 15, 2015
Been working on this program for a while. It's currently broken in several parts but it at least reads and stores the data into the arrays correctly. The problem is writing the sort function and the swap function. The other problem is writing both of these to keep the correct ages with the correct names.
/*
Write a program to allow the user to enter up to ten people with their age.
The names will be a full name consisting of a last, possibly a middle initial, and a first name.
The full name will be no longer than 40 characters in length.
The full will be stored in an array of strings, a two dimensioned array of characters.
The ages will be stored in an array of integers. Manage the arrays as parallel arrays.
Data entry will be from the keyboard and will read the full name followed by the age.
Data entry will terminate when the arrays are full or when nothing is entered for the full name.
Use a subroutine to enter the data and pass the arrays to the subroutine, do not use global arrays.
Once the data is completely entered, use another subroutine to print out the arrays to the screen.
Then use a subroutine to sort the data on the full names, ascending order.
Reuse the print subroutine and print the sorted data out to the screen.
Write another subroutine which sorts the data on age as the primary sort and full name as the secondary sort.
Finally reuse the print subroutine to print the data to the screen.
The main program will call the data entry function, followed by the print function, the name sort function, the print
function, the age sort function and finally the print function.
All data will be passed to the functions, no global data.
*/
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#define SIZE 5
void input(char fullname[][25], int age[]);
void output(char fullname[][25], int age[]);
[Code] ....
View 14 Replies
View Related
Mar 9, 2013
My tasks was to write a program which finds difference between two arrays (elements which are in first array but not in second and vice-versa). Program works, but something wrong is with the memory allocation for array.
My code is:
main.c Code: #include <stdio.h>
#include <stdlib.h>
#include "header.h"
[Code]....
View 5 Replies
View Related
Mar 9, 2014
I have a program matrix multiplication but it work not for big arrays. n should be bis 200.
#include <iostream>
#include <time.h>
#include <cstdlib>
[Code]....
View 6 Replies
View Related
Nov 4, 2013
SO Im supposed to write a program that uses arrays to calculate the sum and display it. I keep getting the error that says the sum has to be initialized.
#include <iostream>
using namespace std;
//Function prototype
int sumArray(int);
const int NUM_ELEMENTS = 5;
[Code] .....
View 1 Replies
View Related
Feb 5, 2015
writing this program where you can search a structure array for existing elements, add new elements to the structure array, and find and display entire elements of the array structure and all.
Right now I am stuck on adding new elements to the structure array.
#include <iostream>
#include <string>
#include <iomanip>
[Code]....
Any methods to displaying the a array structure or editing it ....
View 6 Replies
View Related
Nov 4, 2014
program that generates 5 non duplicate numbers that is between 1 and 20 by using arrays. Here is my code and i cant compile it.
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <iomanip>
using namespace std;
int main() {
srand(time(NULL));
[Code]...
View 3 Replies
View Related
Feb 11, 2013
Write a program that prompts for and reads in test scores. You may assume that valid test scores will be integer values between 0 and 100. You may also assume that the user will not enter more than 35 test scores. Use a preprocessor directive to define this value. User input will be complete when the user enters a -1 for the test score. When all of the test scores have been entered, the program will print out the scores. Use a while or do-while loop to read in the values. Use a for loop to print out the values.
Sample output:
Enter test score 1: 88
Enter test score 2: 67
Enter test score 3: 74
Enter test score 4: 94
Enter test score 5: 79
Enter test score 6: 56
Enter test score 7: -1
Number of scores entered: 6
Test scores entered : 88 67 74 94 79 56
View 14 Replies
View Related
Jun 8, 2014
I have not been using pointers that long i most of my stuff has not needed them but now they do i need to learn how to use them more. I'm writing a program that simulates the squares most landed on(for fun) and i cant get a method to work because of an array pointer.
The error is no matching function for call to 'GameLoop::Loop(int, int (*)[4])'
Here is the latest version of the code. I've been editing a lot of things so there might be some stupid errors but I've tring everything.
rolling.h and rolling.cpp are just some dice function they are working perfect.
main.cpp
#include <iostream>
#include "Rolling.h"
#include "GameLoop.h"
Rolling Roll;
GameLoop Game;
[Code] ....
View 2 Replies
View Related
Apr 22, 2014
I am writing a class that dynamically allocates an array that holds a user-defined number of test scores (test scores go from 0 to 10 both included). Once all the test scores are entered and validated (values only between 0 and 10, both included), the array should be passed to a function that sorts them in ascending order. Another function should be called that calculates theaverage of all the scores.The main program should display the sorted list of scores and the average of the scores with appropriate headings.
View 6 Replies
View Related
Feb 6, 2014
I define "Comwords" as a string, but apparently it takes the members as chars, then I can't set strings in a structure equal to the chars.
I see to also be having unknown problems with the ComMAL array and loading it values into another element of the same structure.
How to correct this? I was thinking of casting char elements as strings, but could find no reference in my library book regarding how to do that (lots on casting int's a doubles...)
Code:
int _tmain(int argc, _TCHAR* argv[]) {
int comm = 10;
int targ = 5;
int death;
struct AI_WORDS
[Code]....
View 2 Replies
View Related
Jul 1, 2014
Using a for loop, construct two 100 element arrays, x and y, such that element i of x stores the value sin(2*pi*i/100)) and the corresponding element of y stores cos((2*pi*i/100)). Print the values stored in the elements of x and y as you calculate them.
I have attempted to solve it but I'm not sure why the value 0 is only being printed, maybe I haven't assigned sin(2i/100)) and cos((2i/100)) to the arrays properly?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main () {
[Code] .....
View 3 Replies
View Related
Dec 17, 2014
int arr[4][5];
for (int(&row)[5] : arr){
for (int &column : row){
} }
Why do we name it row instead column?
int arr[row][column]
Wouldn't this be like
int arr[4][5];
for (int(&column)[5] : arr){
for (int &row: column){
}
It just seems funny to me because we use row[5] which should be 4 if we meant row? Or did I read it wrong in C++ prime !?
View 2 Replies
View Related
Apr 15, 2013
I'm trying to write a function that takes a 32bit address and a data to store at this address.
I'm wanting to take the 32 bit memory address eg 0x12345678 and split it
into 4 x 2 bytes
12, 34, 56, 78
then each of the 4 entries is at most a 256 entry array.eg
FF, FF, FF, FF
So in this example, 0x12 points to 0x34 in the second array, which points to 0x56 in the third array, which finally points to 0x78 in the last array. This last array holds the actual data.
After successfully doing 0x12345678, say I might get a read for 0x1234AABB. So, the first and second pointers already exist, but I then have to create and write to dynamically created arrays.
The arrays need to have all entries set to NULL so that i know whether to follow the pointers to overwrite a previously entered value or create new arrays and pointers.
It all looks good and simple in the pseudo code I've written up but I'm having trouble coding it. I'm currently trying to deal with the first entry case, ie all array elements are NULL, but I'm getting confused with the pointers and creation of new arrays.
void cpu::store(unsigned int mem_add,unsigned int mem_val) {
int first = (mem_address&4278190080)>>24;
int second = (mem_address&16711680)>>16;
int third = (mem_address&65280)>>8;
int fourth= (mem_address&255);
[Code] .....
A1 has been declared as
int* A1[256] ;
View 3 Replies
View Related
Jul 24, 2013
like for example if
Num1[0]=2
Num2[0]=3
this is not working x= Num1[0] + Num2[0];
is there any other way ?
View 11 Replies
View Related
Nov 13, 2013
Basically on this assignment I must write program that inputs two positive integers of at most 100 digits and outputs the sum of the numbers into an array. The two positive numbers must come from different arrays and the sum has to be stored into another array.
View 2 Replies
View Related
Jul 23, 2013
For example if we have
array1[5]= {1,2,3,4,5}
and
array2[5]={2,3,4,0,7)
how do you sum them up as 12345 + 23407 . And when i say sum I mean normal mathematical sum.
here is my code:
int main () {
string str1;
string str2;
[Code].....
View 4 Replies
View Related
Feb 12, 2014
Compiled on turbocpp 4.5.....error is that the final merged array is much bigger with garbage values...
Code:
//cpp program to concatenate 2 arrays
#include<iostream.h>
#include<conio.h>
//the class
class array
[Code] .....
View 6 Replies
View Related