Need Help!

I have a assignment for class and I am not sure where I went wrong.
Here is the assignment: Prompt the user to enter an item name (one word only), a quantity and a price. (Use a string data type for this. You'll need to include a string header.)
For this step, in addition to functionality, I'll be looking at: location of the variable declarations; appropriateness of data types selected; appropriateness of the variable names; variable naming standards.
Calculate the subtotal (quantity * price), tax (tax rate is 7.5%), and total (subtotal + tax).
For this step, in addition to basic functionality, I'll be looking at: whether you used a constant; how the naming standard for the constant and appropriateness of the name. The accuracy of the calculations.
Finally, display the item name, quantity ordered, price, subtotal, tax, and total.
In addition to basic functionality, I'll be looking for: formatted output, output that is centered vertically and horizontally; floating point data aligned on the decimal.
BLING: Include a splash screen (not the clown. Find an ASCII art image for yourself. A good resource is followed by a welcome message. Implement these two features as functions. Your program should contain three functions: main(), splash(), and welcome(). ONLY!

if there is anyone willing to help me, please send me a message.
closed account (zb0S216C)
I take it you weren't listening in class? If so, then go here:
If you were listening, then you should know how to do it.

Its a online class, and i have no option to have in-class session due to work.

I have a program written, just not sure if I have it written correctly.

closed account (zb0S216C)
If you post it, we can look it over.

using namespace std;
void welcome();
//global constants
const float TAX_RATE = 7.5;

int main(int argc, char *argv[])
int ;
float subtotal, quantity, price, tax;
cout << showpoint << setprecision(2) << fixed;

cout << "n\n\n"
<< .-""""--.
<< / )
<< / --"`
<< / _`:---.
<< | .-' `\
<< \ / .----'./
<< \ : ,-' ~(.).)\
<< \_| \ ._) |
<< / | \.__, /
<< _.--' )`///-,-'
<< / / _| (_\\
<< | (____/____)
<< \ ___/ | _
<< `---( ` )
<< `-, .'
<< (__.'._/'._/
<< |`| |
<< __ / / /
<< // | `--.
<< || /_____)
jgs << `=---`

<< "\n\t\t" ;

//input section
cout << "Enter one item name";
cin >> name;

cout << "Enter the item price: $";
cin >> price;

cout << "enter the quantity: :;
cin >> quantity;

//processing section
subtotal = quantity * TAX_RATE;
tax = price * TAX_RATE;
total = subtotal + tax;

//output section
cout << "\n\n\n\n\n\n\n\n\n";
cout << "\t\t\tYour subtotal: $" << setw(7) << subtotal << endl;
cout << "\t\t\t Your total is $" << setw(7) << total << endl;
cout << "\t\t\t Your tax is $" << setw(7) << tax << endl;
cout << "\n\n\n\n\n\n\n\n\n";

one thing I can tell ya right now is your ascii bit isn't going to fly as is.

string literals must be enclosed by quotes ""
quote marks " and backslash \ are special characters that are handled differently than regular characters. if you want to stream them to cout, preface these characters with a backslash like this: \" or \\
then they will print the character instead of ending the string.
another special character is \n and you need to use this to end each line you have there in your ascii pic. so it should look more like this:

cout << "\n\n\n"
<< ".-\"\"\"\"--."
<< "/ )"
<< "/ --\"`"
<< "/ _`:---."
<< "| .-' `\\"
<< "\\ / .----'./"
<< "\\ : ,-' ~(.).)\\"

also enclose jgs in quotes: "jgs" unless it's a variable you've declared.

also the control structures are all messed up.
get rid of the set of {} brackets around the ascii bit. they don't belong.
also the lines:

void welcome();

declare and call a function that isn't really defined anywhere may as well just get rid of those two lines.
the bracket at the very end needs to be } the other way.

this line:
cout << "enter the quantity: :;

needs to be fixed:
cout << "enter the quantity: ";

may want to do this too:
cout << "Enter one item name";
cout << "Enter one item name: ";
that'll look nicer.

also these lines..
cout << "\n\n\n\n\n\n\n\n\n";
may be a little trigger happy with the "\n"s lol calm down bub
i mean calm down missy :p

and this line at the top:

int ;

delete that.
Last edited on
and don't forget to put this at the top!

#include <iostream>

oh and I'd get rid of these two \t's

<< "\n\t\t" ;
they're gonna push your prompt: "Enter one item name" over two tabs..

and the variable "total" remains undeclared.. put that up there with yer floats declaration
Last edited on
Topic archived. No new replies allowed.