C/C++ :: Record Multiple Inputs For 2 Orders On 2 Different Registers?

Feb 26, 2015

The tools Hal's sells are: Hammers: $10.99 Wrenches: $10.99 Levels: $19.99 Tape Measures: $4.99 Screwdrivers: $8.99

In order to make things easier in the long run you have decided to make a c++ program that takes in all the orders for each register and tallies them at the end of the day.

Write a c++ program that does the following:

Create a Register class that can store all of the receipts for the day and the totals for that register.

This class could have the following member functions:

Contructor(int) - Creates a number of receipts based on an integer that is passed into the constructor (this is the largest number of orders that the register can take). You may also be required to create additional variables to make the program work but that's up to you to determine.

void getorder() - Asks the user how many of each item they want an stores that in the first available receipt.

void returnreceipts() - This function returns the details of all the receipts and the total for the day.

Register operator+(const Register &right)- This is an overloaded addition operator. When two objects are added together an empty temporary register is created (with 0 receipts) and only the totals of both objects are added to it. The temporary register is returned by the function.

Register operator=(const Register &right)- This overloaded assignment operator copies only the totals from the Object on the right.

In the Main function I would like:

Create 3 Register Objects. The first two registers are the ones in the store and should be initialized to take 10 orders. The third is used at closing time and can be initialized with 0 receipts as it will only take in the totals from the other registers.

Run the getorder function for registers 1 and 2 twice.
Run returnreceipts for register 1 and register2.
Reg3=Reg1+Reg2;
Run returnreceipts for register 3.

[Code]...

this is what I have so far I'm trying to get the input part working first, so the user would be asked each item individual how many they want? this will happen for 2 users, then the next register will do the same?

View 2 Replies


ADVERTISEMENT

C++ :: Using Cin That Accept Multiple Inputs

Feb 14, 2013

For a program I am required to use a cin that accepts 4 variables. The first describes a function such as add(), remove(), print(), or quit(). The problem is that to use add() I need to input all 4 variables but for remove(), only 2 variable input is needed.

I want the input to be "add 9 James Bond"
or be "remove 341"

Here is my current code.

int command(string command, int Id, string first, string last){
while (command != "quit"){
cout << "customers> ";
cin >> command >> Id >> first >> last;
if (command == "add")

[Code] .....

View 1 Replies View Related

C :: Processing Outputs Of Multiple Inputs

Nov 26, 2013

It's not something trivial but I would like to know the best way to process multiple outputs, for example:

Input
First line of input will contain a number T = number of test cases. Following lines will contain a string each.

Output
For each string, print on a single line, "UNIQUE" - if the characters are all unique, else print "NOT UNIQUE"

Sample Input
3
DELHI
london
#include<iostream>

Sample Output
UNIQUE
NOT UNIQUE
NOT UNIQUE

So how can I accomplish outputs like that? My code so far is:

Code:
int main(int argc, char *argv[]) {
int inputs, count=0;
char str[100];
char *ptr;
scanf("%d",&inputs);

[Code] ....

But the above will obviously print the output after each input, so I want to know how can I achieve the result given in the problem. Also another thing I want to know is, I am using an array of 100 char, which it can hold a string up to 100 characters, but what do I have to do if I want to handle string with no limit? Just declaring char *str is no good, so what to do?

View 5 Replies View Related

C :: Reading Multiple Inputs Sscanf

Jan 23, 2014

I am beginner at C and I was working on a program where I have to read in a line such as Digit, String, Float. The string can have any amount of spaces between it. and each input is separated by a space character.

The input is of the format:

10000000000 hello my n ame is 30.2

So I used fgets(x,100,stdin) to read the line in.

So I need to read that line into an int, array, and float.. so I was thinking of using this:

sscanf(x, "%d %[^/n] %f", &number, &username, &numberfloat);

Now, obviously I can't use the /n to read in the username with spaces because I need to read the 30.2 into a float variable.

View 5 Replies View Related

C++ :: Running Same Code With Different Inputs On Multiple CPUs

May 28, 2014

I have a C++ code reading large data from an input txt file, doing some calculation on the data, and writing the result of calculation in another txt file.

I have about 300 input files, and the calculation time for each input file is pretty long (~4 days on a single CPU), so I would like to run the same code on multiple CPUs for different inputs.

Which is the most appropriate strategy in this case, multithreading, mpi or something else?

View 4 Replies View Related

C++ :: How To Access Certain Elements And Store Multiple Inputs

Jan 20, 2014

am trying to create a program that asks the user personal questions.

std::vector<std::string> name, age, favsinger;
std::cout << "Hello, what is your Name Age Favorite_Singer? ";
std::cin << name; //i want to store the user's info along with the sibling's

[Code]....

View 4 Replies View Related

C++ :: Using Union For Combining Registers

Nov 16, 2013

How I could use unions to combine registers elegantly. For example I have the 8 bit registers B and C & I have opcodes that work on each independent register such as add b, c, which is simple, but then I also have opcodes that work on both of them as if they're one like ld a, bc. I know I could go about that by just masking them together but I've seen it done with unions before & it made everything so much more simple.

View 4 Replies View Related

C++ :: Sorting 3 Numbers By Ascending Orders?

Jan 30, 2015

We've only covered up to Functions and how to use reference variables inside the function parameter.

One of the hw problem that was assigned was to write a void function that takes three parameters( num1, num2, num3) by reference and sorts their values into ascending order, so that num1 has the lowest, num2 the middle value, and num3 the highest value. For example, if user enters: 14, -4, 8, then the output should look like this:

-4
8
14

I've completed the program with a bunch of if/ else if statements but I was wondering if there was a more efficient way to sort the numbers. Bear in mind, we've only covered materials up to functions so I can't use any other new techniques that we haven't cover yet. Here is my code:

// This program will take three int parameters by reference and sorts their value into ascending order
//so that num1 has the lowest value, num2 has the middle value, and num3 has the highest value
#include <iostream>
using namespace std;
// declare function with reference parameter that with sort numbers
void sortNum(int &, int &, int &);
int main ()
{

[Code]....

View 2 Replies View Related

C++ :: Eliminating Jumping Repetitions Of Different Orders

Feb 26, 2014

I wrote a program for class. It did its job, but I want to make it better. The program finds all of the Pythagorean triples between 1 and 100.

As you can see, the program will repeat the same Pythagorean triples but in different orders.

What I want to do is have the program repeat each Pythagorean triple once, regardless of whether the ordering is different. I have tried, but only came up with the solution to solving repetition that is consecutive. But the repetition for Pythagorean triples jump around.

I got stuck on how to eliminate jumping repetitions. I only know how to make it not repeat on consecutive entries.

View 5 Replies View Related

C/C++ :: How To Sort The Names In Alphabetical Orders

Jul 29, 2014

#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main() {
const int arraySize=20;

[Code] ....

View 5 Replies View Related

C/C++ :: Eliminating Jumping Repetitions Of Different Orders?

Feb 25, 2014

I wrote a program that finds the Pythagorean triples for class. It did its job, but I want to make it better. The program below finds all of the Pythagorean triples between 1 and 100.

As you can see, the program will repeat the same Pythagorean triples but in different orders.

What I want to do is have the program repeat each Pythagorean triple once, regardless of whether the ordering is different. I have tried, but only came up with the solution to solving repetition that is consecutive. But the repetition for Pythagorean triples jump around.

E.g., Pythagorean triple (6, 8, 10) appears. Then two Pythagorean triples later, (8, 6, 10) appears.

I got stuck on how to eliminate jumping repetitions. I only know how to make it not repeat on consecutive entries.

I nested one for loop, in another for loop that is nested in another for loop. One for loop for each of the values in the triple. The most nested loop is for the c value in a^2 + b^2 = c^2, and has an if statement: if( ((a*a)+(b*) == (c*c) ) , and then the program prints the numbers.

#include <iostream>
#include <cmath>
using namespace std;
int main() {
unsigned int a, b, c;
char con;
cout << "This program finds the pythagorean triples between 1 and 200.

[code].....

View 5 Replies View Related

C# :: Server-side Validation For Deleting Orders In Progress

Apr 18, 2014

[URL]

According to my project instructions, I have to make a "validation on the delete button, that before a record can be deleted it will check to see if the count of "In-Progress" orders for that product is 0. If it is greater than zero, it should not allow this record to be deleted."

So far I have on the code behind page:

protected void btnDeleteProduct_Click(object sender, EventArgs e)
{
DataView dv = (DataView)SqlOrders.Select(DataSourceSelectArguments.Empty);

[Coe].....

The professor said I have to: "As for getting the count, check your notes and book, specifically looking at SQL and the Aggregate functions. There is a function we talked about in class called "Count(OrderID)" and set the where clause to check for the productID.

View 2 Replies View Related

C :: How To Search For Record And Deletes It

Apr 9, 2013

I am trying to get my program to search for the account ID in the structure and deletes the record as the account ID is found. The problem is that my codes are not working. (since my whole program is too long, I only show a part of it.) Here are my codes:

Code:

#include <stdio.h>
#include <string.h>
struct Account
{
char* Account_ID;
char* AccountOwner_FirstName;
char* AccountOwner_LastName;
}

[code]....

View 4 Replies View Related

C++ :: Adding New Record To Array?

Feb 1, 2013

I'm having some issues with adding a record to my array.

#include <iostream>
#include <fstream>
#include <string>

[Code].....

View 2 Replies View Related

C/C++ :: Student ADT - How To Delete A Record

Feb 24, 2014

My assignment for class was to create a Student ADT. I have three files. First one is Student.h which defines a Student record and has the prototypes of the functions that can be used with Student. I have Student.cc which is where the functions are actually declared. And my final file is testStudent.cc where the "main" function is that is creating a Student and callign all of the functions to make sure they work properly.

I have all of the functions working properly, except for my destroyStudentRecord function. It is supposed to deallocate the record, but I am unsure of how to actually do this. The current implementation appears to only deallocate the firstName field, as when you display the record after deallocationg it, everything still shows up except the first name. I have tried deallocating each field of the record before deallocating the record itself and that gave me the biggest list of errors I have ever seen.

I realize the implementation of some things in here might be a bit odd, but this is exactly how we are required to do things for this assignment and nothing about the implementation can really be changed unless something is actually just plain wrong(which is of course a possibility as I am quite new to this!). As I said though, everything else is working exactly as it should be, so my only issue at all is with actually deleting the record once I have created one.

Student.h:

#include <iostream>
#include <cstdlib>
using namespace std;
#ifndef _STUDENT_H_
#define _STUDENT_H_
struct Student {

[Code] ....

View 9 Replies View Related

C++ :: How To Sell Record / Title

Sep 24, 2014

Alright I no longer have compiler errors. I require writing code for selling a record. How would I go about that?

#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <cctype>
#include <conio.h>
using namespace std;
//declare variables
void Add();

[Code] ...

View 9 Replies View Related

C++ :: Reading From TXT File That Is A Record

Apr 18, 2014

I'm working on a program using class booktype... to hold information about various books that I have saved on a txt file. Each object of the class book type holds the author, publisher, ISBN, number of copies in stock.

I am still very much new at c++ and not exactly sure how to get in info from the file I've made earlier..

Code:
#include<iostream>
#include<iomanip>
#include<string>
#include<cstring>
#include<fstream>
using namespace std;
class bookType {

Also the text file is formatted where after I've entered the author's name I then hit return, then publisher then I hit return, ISBN then return, and so forth does that effect the program? As for my txt file this is what I have

Code:
Moby Dick
Sebastian Armesto
Oberoson Books Ltd
0001
201
The Scarlet Letter

[Code] ....

View 6 Replies View Related

C :: Program Crashing When Deleting A Record

May 5, 2013

Code:

#include<stdio.h>
//bookData structure
struct bookData {
int recordNum;
char description[ 15 ];
int booksBought;
double bookCost;

[code]...

I am able to add records and show records, no problem. But when I go to delete a record, it crashes immediately after inputting the record number I want to delete. I don't see why. I've set it up exactly like the example in my book, having of course changed the variable names for my program. Does it have something to do with the pointer?

View 3 Replies View Related

C++ :: Structure Record Type In Array

Feb 24, 2015

I have to enter the Instructor ID and invokes getFees to find the fees of the given instructor. Then it will displays the message that shows either the fees or "No such instructor ID" if not found. the function prototype is

double.getProfessionFees(string);
#include <iostream>
using namespace std;
const int DECLARED_SIZE = 7;
int search(const int a[], int number_used, int target);
struct InstructorType

[Code]....

View 7 Replies View Related

C++ :: Deleting A Record From Struct Array?

Aug 31, 2014

I want to delete selected records from struct array using cstring reading from files. Here I read my records to stud struct then assign non-deleted to stu struct but its not deleting as desired...strcmp is giving 25

while(cont=='Y'){
cout<<"Enter student ID to delete: ";
cin.ignore();
cin.getline(id, 15,

[Code] ....

I did some debugging effort and I found here is the problem..the stud[0].ID and id is not same but why? I am giving in same id and both char array lenght is 15

while(cont=='Y'){
cout<<"Enter student ID to delete: ";
cin.ignore();
cin.getline(id, 15);
cout<<strlen(stud[0].ID)<<" "<<strlen(id)<<endl;///---> lenght 1 is 10
///---->lenght 2 is 8
cout<<strncmp(id,stud[0].ID, 10 )<<endl;

View 2 Replies View Related

C/C++ :: Reading In Record In Text File Twice?

Dec 1, 2014

I am working on my final project for my intro to c++. Its a simple program where you buy a car, choose parts for it, see the price of it in total, buying option, and to view past records.

So my problem lies with displaying the records. For some reason(doesn't many how many records there are) the very last record displays again without the "Model" part, but displays the rest of them fine. In other words, there are 2 problems, the last record is displayed twice, 2nd that added record displayed is missing the "model"(this problem doesn't matter really if you can solve the first problem, but would still like to know why it does that).

I tried debugging it and I believe the problem lies with the --------while(fName.good()). It just decides to repeat it again even though in the text file, it does not have that extra record.

//inventory
void viewInvent(string fName)
{
//variables

[Code]....

View 3 Replies View Related

C# :: Rdlc Report Does Not Show First Record

Apr 7, 2014

I use rdlc report in C# . I have a Table Item in the form to show all record but it show all record except first record .

View 4 Replies View Related

C# :: How To Check If Record Exists In A Join

Apr 25, 2014

I have to check whether or not a record exists in a join and if not ignore that user but still load all the other information for that user

var db = Simple.Data.Database.OpenNamedConnection("sqlConn");
var expr1 = db.PON_APP_USERS.STATUS == 1;
var sUsers = db.PON_APP_USERS.FindAll(expr1)
.Select(
db.PON_APP_USERS.USERKEY,
db.PON_APP_USERS.LAST_NAME,
db.PON_APP_USERS.FIRST_NAME,

[Code] .....

View 8 Replies View Related

C# :: Update Then Delete Record In Datagridview

Apr 21, 2015

In my project i need to update the attn_dateTimeOut in database.After i updated it will automatic delete the specific row record that had been updated. I had two question:

1) in my database there are a few table is assign not null."attn_dateTimeOut" is a table that haven insert any record. When i update it using below code,it work and can update but it comes out error.Error show "record cannot be null".

2) I want t make it when i updated the "attn_dateTimeOut",it will auto delete the row of updated record.I do usign back code "DeleteRecord" but it nothing change!How should i do?

Here my code:

private void txt_proximity_KeyPress(object sender, KeyPressEventArgs e) {
if (e.KeyChar == (char)13) {
TMPB_attn row_TMPN_attn = BusinessLogicLayer.TMS_GET_PROXIMITY_VALID_TO_USE(txt_proximity.Text);
if (!String.IsNullOrEmpty(txt_proximity.Text)) {

[Code] .....

View 1 Replies View Related

C/C++ :: File Search Not Starting At First Record

Aug 10, 2014

Below is a snippet of my code in which it loops through a file trying to find the matching record of a selection given by the user. I use tellg() to tell me where the search begins and it does in fact start at the beginning. But when the search actually executes, it starts at the last record, loops once, and ends, as it does not find the matching record (when the user enters '24' for example)

void Hardware::updateExistingRecord(ofstream &addRecordInfo, ifstream &updateRecord, Hardware &_records) {
//selection on which field to update
enum Field { RECORD_NUMBER = 1, TOOL_NAME, QUANTITY, COST, EXIT };
cout << "Enter record number you would like to update
";
cout << "Enter zero to exit
?";

[Code] ....

View 10 Replies View Related

C/C++ :: Delete Record From Binary File?

Jan 12, 2013

How To Delete A Record From binary File - C++ ?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved