PDA

View Full Version : [OT] Help me with my program.. lol



Vid Gamer
16-02-04, 07:14
I'm having trouble getting the correct output of this C++ program. Here's the code:


#include<iostream.h>

int main()
{
const float QuarterNum = .25;
float QuarterNumSum;
const float DimeNum = .10;
float DimeNumSum;
const float NickelNum = .5;
float NickelNumSum;
const float PennyNum = .1;
float PennyNumSum;
float TotalDollars;
float TotalCents;

cout<<"Enter the amount of quarters. ";
cin>>QuarterNumSum;
cout<<"Enter the amount of dimes. ";
cin>>DimeNumSum;
cout<<"Enter the amount of nickels. ";
cin>>NickelNumSum;
cout<<"Enter the amount of pennies. ";
cin>>PennyNumSum;
TotalDollars = QuarterNum + DimeNum + NickelNum + PennyNum;
cout<<"Total is " <<TotalDollars<< "dollars and " <<TotalCents<< "cents."; endl;
return 0;
}

What I need to do is have it print "The total is _______ dollars and ________ cents." but I am having some trouble in doing that.

Would anyone know? :(

Lucid Dream
16-02-04, 07:24
havent done c++ in a bit but lets see if i remember...

#include<iostream.h>

void main()
{
int quarters = 0;
int dimes = 0;
int nickels = 0;
int pennies = 0;

double total = 0;

cout<<"How many quarters?"<<endl;
cin>>quarters;
cout<<"How many dimes?"<<endl;
cin>>dimes;
cout<<"How many nickels?"<<endl;
cin>>nickels;
cout<<"How many pennies?"<<endl;
cin>>pennies;

total = ((nickels * .25)+(dimes * .1) + (nickels *.05) + (pennies *.01));

int dollars = total;
double cents = total-dollars;

cout<<"The total is "<<dollars<<" dollars and "<<cents<<"cents"<<endl;

}



now, keep in mind i havent done c++ in like a year, so none of this might work, but its a possibility lol.

Shujin
16-02-04, 07:26
im t00pid

Vid Gamer
16-02-04, 07:38
Heh, I'll try it. =/

Vid Gamer
16-02-04, 07:49
Awesome, it worked.

Thanks a bunch.

Lucid Dream
16-02-04, 08:10
Whoa, cool... np lol

Vid Gamer
16-02-04, 08:18
Yeah, at first it looked a bit iffy and I had to edit and add some minor things but in the end it worked out much better then what I was doing. :)

Lucid Dream
16-02-04, 08:52
Cool hehe, glad to be of help =)

Shujin
16-02-04, 09:28
Originally posted by Lucid Dream
Cool hehe, glad to be of help =) btw lucid ;] congrats u seem to be winnin the inc. section of the skin contest with that nice head ;D *looks at mirror* btw it was made off me ;P anyway what have you been thinkin about getting as prize?

Vid Gamer
16-02-04, 09:30
Don't go offtopic in my thread biznatch!

Shujin
16-02-04, 09:35
Originally posted by Vid Gamer
Don't go offtopic in my thread biznatch! teh topic is 0ver f00ness


btw either of u play eve?

Vid Gamer
16-02-04, 09:36
All I have to say is for a Mod to close this and it will go bye bye. :p

But I'm a nice guy and I'll let you stay here. I beta'ed EVE and thought it was pretty craptacular.

Shujin
16-02-04, 09:37
its pretty fun, but im a bit tired of spendin all my money on a ship then the ship blowin up and having to mine about a week to get enough money to get another ship to get blown up.

Vid Gamer
16-02-04, 09:48
Yeah, I remember asking what do I do to start off and people were like you gotta mine asteroids for money and I was like... o_O .. aight im out. lol

Agent L
16-02-04, 12:00
printf pwns cout !!