I have an assignment that i need to do and i have no idea how to do this, I was hoping someone would be nice enough to help me out, its a begginner program that needs to be done in visual stdio c++:

Heres the assignment:

Try to write a C++ program to solve the following problem.
PROBLEM:
The New Wave Computer Company sells its product, the NW-PC for $675. In addition, they
sell memory expansion cards for $69.95, disk drives for $198.50, and software for $34.98 each.
Given the number of memory cards, disk drives, and software packages desired by a
customer purchasing a NW-PC, print out a bill of sale that appears as follows:
**********************************************
NEW WAVE COMPUTERS
ITEM COST
1 NW-PC $675.00
2 MEMORY CARD $139.90
1 DISK DRIVE $198.50
4 SOFTWARE $139.92
-----------
TOTAL $1153.32
note: You should prompt the user for the number of memory cards, disk drives,
and software.
Do the above for 3 customers and output the grand total at the end as well as the 3 bills for sale


Thanks in advance!!

Recommended Answers

All 18 Replies

Here's a hint.

Start by writing a program that reads a number and prints it out again.

I've noticed a lot of posts here with kids wanting their homework done.

Is this a new thing or has it always gone on? and does anyone ever fall for it?

I've noticed a lot of posts here with kids wanting their homework done.

Is this a new thing or has it always gone on? and does anyone ever fall for it?

Yes and Yes. Although people who give the codes away without any effort from the receiving end and those who receive them usually get -rep.

I made a topic a while ago, sadly no one has added a response. =/

@ hq1, Start of with this:

#include<iostream>
using namespace std;
int main(){
}

Then work your way up! ;D

lol the problem is i know how to get to some points its that i dont have visual studio on my computer at home b/c it is really slow and old. I use the computer at school, but the assignment is due tmrw

lol the problem is i know how to get to some points its that i dont have visual studio on my computer at home b/c it is really slow and old. I use the computer at school, but the assignment is due tmrw

That gives you a few options.
Either:
a) Download the program and deal with the sluggish processing.
b) Do your work in school. (Staying after, during class time, etc.)
c) Use notepad. If you were really paying attention in class I am sure you could get the 'gist' of your program done, and quickly fix it up in school once you have the program.
d) Attempt to program it, get stuck, and come here for help. (Yes we do help others, but only if there was an attempt made at solving the problem.)

Hope this helps you with your future homework endeavors. =]

okay so im just guna work on the above assignment at school, but i have this other assignment that i did below, it reads from keyboard but i also need it to read from file, how do i do that?

The following program reads a number from the keyboard continuously until a
value of -999 is encountered.
//File: lab1b.cpp
// The following program reads in a number from the keyboard continuously until a value of
// -999 is encountered.
// This program converts the input value from centigrade to fahrenheit.
// Input value: centigrade
// Output value: fahrenheit
#include <iostream>
#include <iomanip>
#include <conio.h>
using namespace std;
void main ()
{
// local values
float centigrade, fahrenheit;
// Prompt user for input value
cout << "Enter a whole number for centigrade :" << endl;
cout << "If you wish to stop enter -999 : " << endl;
// Enter input value
cin >> centigrade;
while (centigrade != -999)
{
// Calculate fahrenheit
fahrenheit = centigrade * 9 /5 + 32;
// Output fahrenheit
cout << "Fahrenheit of " << setprecision(5) <<centigrade
<< "is "<< setprecision(5) <<fahrenheit << endl;
// Prompt user for another input value
cout << "Enter a whole number for centigrade :" << endl;
cout << "If you wish to stop enter -999 : " << endl;
cin >> centigrade;
} // end while loop
} // end program 

Write the code in code tag (CODE)......
My suggestion to is that try to do some, your problem is that did't want to do any thing your a lazy person and no one is here to help a lazy person.
In your not a single is mention related to file that means either you don't know any thing about file or you did't try, so first try it by your self other wise I don't think will get any help from any one in this web.............
Best Of Luck.

>>>i dont have visual studio on my computer at home b/c it is really slow and old

Try using online compilers like ideone:

www.ideone.com

You can also try to run your program using turbo c++ compiler down load it........and try to run ur program on turbo c++ .......

The following program reads a number from the keyboard continuously until a
value of -999 is encountered.
//File: lab1b.cpp
// The following program reads in a number from the keyboard continuously until a value of
// -999 is encountered.
// This program converts the input value from centigrade to fahrenheit.
// Input value: centigrade
// Output value: fahrenheit
#include <iostream>
#include <iomanip>
#include <conio.h>
using namespace std;
void main ()
{
// local values
float centigrade, fahrenheit;
// Prompt user for input value
cout << "Enter a whole number for centigrade :" << endl;
cout << "If you wish to stop enter -999 : " << endl;
// Enter input value
cin >> centigrade;
while (centigrade != -999)
{
// Calculate fahrenheit
fahrenheit = centigrade * 9 /5 + 32;
// Output fahrenheit
cout << "Fahrenheit of " << setprecision(5) <<centigrade
<< "is "<< setprecision(5) <<fahrenheit << endl;
// Prompt user for another input value
cout << "Enter a whole number for centigrade :" << endl;
cout << "If you wish to stop enter -999 : " << endl;
cin >> centigrade;
} // end while loop
} // end program

HAPPY?

>>HAPPY?
The attitude really isn't necessary. On our end, it is significantly easier to help someone if they use a proper code tag because it helps make the code easier to read. I wasn't going to say anything, but since you asked. Properly formatted code is even better still, it makes the structure easily visible, if there is a scoping issue, it is much easier to spot, among other things.

Compare this to your post, see the difference in readability?

//File: lab1b.cpp
// The following program reads in a number from the keyboard continuously until a value of
// -999 is encountered.
// This program converts the input value from centigrade to fahrenheit.
// Input value: centigrade
// Output value: fahrenheit

#include <iostream>
#include <iomanip>
#include <conio.h>

using namespace std;

void main ()
{
  // local values
  float centigrade, fahrenheit;

  // Prompt user for input value
  cout << "Enter a whole number for centigrade :" << endl;
  cout << "If you wish to stop enter -999 : " << endl;

  // Enter input value
  cin >> centigrade;

  while (centigrade != -999)
  {
    // Calculate fahrenheit
    fahrenheit = centigrade * 9 /5 + 32;

    // Output fahrenheit
    cout << "Fahrenheit of " << setprecision(5) <<centigrade
      << "is "<< setprecision(5) <<fahrenheit << endl;

    // Prompt user for another input value
    cout << "Enter a whole number for centigrade :" << endl;
    cout << "If you wish to stop enter -999 : " << endl;
    cin >> centigrade;
  } // end while loop

} // end program

Regarding your initial query:
Did you see my suggestion in my previous post? To access a file for I/O operations, you need to use the classes and functions contained in the <fstream> header. Have a look at that and the tutorial I linked for you.

Oh, and I just noticed that your main() is specified with a void return. That is not correct. You must always return an int from main().

Thanks bro! i figure out how to do it from file! Owe u one and sorry bout the attitude didnt mean to come across that way, but im still having trouble with what i originally posted for

The New Wave Computer Company sells its product, the NW-PC for $675. In addition, they
sell memory expansion cards for $69.95, disk drives for $198.50, and software for $34.98 each.
Given the number of memory cards, disk drives, and software packages desired by a
customer purchasing a NW-PC, print out a bill of sale that appears as follows:
**********************************************
NEW WAVE COMPUTERS
ITEM COST
1 NW-PC $675.00
2 MEMORY CARD $139.90
1 DISK DRIVE $198.50
4 SOFTWARE $139.92
-----------
TOTAL $1153.32
note: You should prompt the user for the number of memory cards, disk drives,
and software.
Do the above for 3 customers and output the grand total at the end as well as the 3 bills for sale


Thats the inital problem i have to program. I cant figure out how to prompt the user to enter the amount of items of each he needs and then how to get the program to multiply by the selling price and total the cost

I think the important question at the moment is whether this program works on a menu system (i.e. "What kind of item would you like? How many of that item would you like?") or a pre-determined series of prompts (i.e. "How many of this item would you like? How many of the next item would you like? etc...). Which one you need makes a big difference in how you approach the logic.

As evidenced by your previous question, you already know how to prompt the user for information. Now, you just need to figure out when to prompt and what for. Then you need to determine what to do with the provided input.

Oh, I need to prompt the user for how many of each item they would like, such as "how many Memory cards would you like?" and i need the program to be able to multiply the cost of the items by the amount of each item they need and total it for me

I understand that. I was asking about order of operations...
Do you need this?

Welcome to menu program.
Main Menu:
#   Desc.
1.  Option 1
2.  Option 2
3.  Option 3
Please enter an option: [B]2[/B]
How many of 2 would you like: [B]1[/B]

Your current order:
Item:     Qty:
Option 1: 0
Option 2: 1
...

Or do you need this?

Welcome to sequential prompt program.
Enter quantity of Option 1: [B]2[/B]
Enter quantity of Option 2: [B]5[/B]
Enter quantity of Option 3: [B]3[/B]

Your current order:
Item:     Qty:
Option 1: 2
Option 2: 5
...

The logic for the 2 styles is drastically different.

I need this :

Welcome to sequential prompt program.
Enter quantity of Option 1: 2
Enter quantity of Option 2: 5
Enter quantity of Option 3: 3

Total Cost: $...

Start by creating each of the prompts that you need, then fill in between them with some sort of accumulator. Your book should have something in it about these.

Once you have finished inputting your quantities, show your results.

prompt for quantity of object 1
input object 1 quantity
multiply object 1 quantity by object 1 price, add result to order total
rinse and repeat as required
...
display object 1 name, quantity and total
r&r as req'd
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.