HardwareHeaven.com

HardwareHeaven.com

Looking for the skin chooser?
 
 
  • Home

  • Hardware reviews

  • Articles

  • News

  • Tools

  • Gaming at HardwareHeaven

  • Forums

 

Go Back   HardwareHeaven.com > Forums > Software / Tools > Programming, Coding, (Web)Design


Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people.

Reply
 
Thread Tools
Old Sep 15, 2003, 03:32 AM   #1
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
rolleyes Need some help on a C++ program for class

Can you guys help me here? I need to add a statement to this program or modify it so that after each condition it asks the user if he wants to enter another value again... meaning, if he wants to restart the program from the beginning......





#include <iostream>
using namespace std;

int main()
{
const double OUNCES_PER_TON = 35273.92;
double ounces, tons, boxes;

cout << "Enter the weight of ceral in ounces:\n";
cin >> ounces;

tons = ounces / OUNCES_PER_TON;
cout << "The single box of cereal weighs " << tons << " metric tons." << endl << endl;

if (tons == 1)
{
cout << "You do not need any additional boxes of cereal." << endl;
return 0;
}

else if(tons > 1)
{
cout << "You have exceeded 1 metric ton." << endl;
return 0;
}


else (tons < 1);
{

boxes = OUNCES_PER_TON / tons;
cout << boxes << " boxes would be required to equal 1 metric ton." << endl;
}


return 0;
}
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote


Old Sep 15, 2003, 05:25 AM   #2
Unbiased.
 
Join Date: Jun 2002
Posts: 4,812
Rep Power: 0
ToshiroOC is on a distinguished road

Put it in a do loop that checks for an "exit" value, and if the user decides to quit, set exit to 1 before the do expression is evaluated.
__________________
[img][/img]
[color=White]Peace be with you, Joe.[/color]
Driverheaven Staff Member (Supermoderator)
ToshiroOC is offline   Reply With Quote
Old Sep 15, 2003, 05:34 AM   #3
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

Re: Need some help on a C++ program for class

you can use the [code ] tag in these posts
Quote:
Originally posted by DriveEuro
Can you guys help me here? I need to add a statement to this program or modify it so that after each condition it asks the user if he wants to enter another value again... meaning, if he wants to restart the program from the beginning......
To do that . . .
take the section between *'s,
Code:
#include <iostream>
using namespace std;

int main()
{
	const double OUNCES_PER_TON = 35273.92;
	double ounces, tons, boxes;

***********************************************
		
	cout << "Enter the weight of ceral in ounces:\n";
	cin >> ounces;

	tons = ounces / OUNCES_PER_TON;
	cout << "The single box of cereal weighs " << tons << " metric tons." << endl << endl;

	if (tons == 1)
	{	
		cout << "You do not need any additional boxes of cereal." << endl;
		return 0;
	}
	
	else if(tons > 1)
	{
		cout << "You have exceeded 1 metric ton." << endl;
		return 0;
	}

	
	else (tons < 1);
	{		

		boxes = OUNCES_PER_TON / tons;
		cout << boxes << " boxes would be required to equal 1 metric ton." << endl;
	}

***********************************************

	return 0;
}
start a loop just before it,
add a question at the end of it asking if he wants to repeat,
"cin" that to a variable "answer",
and close the loop

set the loop's ending condition to be based on the answer.
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 05:34 AM   #4
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

Lol tosh
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 05:37 AM Threadstarter Thread Starter   #5
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
Here's the thing Joe.... We've been in class 3 weeks. I can't do something extravagent.... I came online cuz our book sucks a fat one. I tried to consult the online help thingie from my book but the website shows "coming soon" for the online help for my book. The book doesn't have an example of how to write a do loop with an IF statement inside of it. I experimented a little and I cannot get it to work. Programming is prolly my biggest fallback on computers. I can't program and it's hard for me to comprehend sorta....

Can someone make me a mock example or how a DO statement would look with an IF statement inside? I mean, programming is a bitch for me, I really struggle with this...
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 05:38 AM Threadstarter Thread Starter   #6
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
Tosh, I did that........ maybe i fUx0red something up, but I did do that..
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 05:43 AM   #7
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

Code:
[your code here]

int answer

do
{
[your code here]
output: "wanna repeat? (1 for yes, 2 for no)"
input to: answer
} while (answer = 1)
only thing is I dunno if that's what the "do" looks like in C++, a quick search on google will tell you how it looks
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 05:47 AM Threadstarter Thread Starter   #8
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
OK, yes, i'm a total n00bie to this..... and i'm lost..... what cose would i stick in the third line of the DO statement there vampy?
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 05:48 AM   #9
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

the code between the ***'s in the above post
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 05:56 AM   #10
Unbiased.
 
Join Date: Jun 2002
Posts: 4,812
Rep Power: 0
ToshiroOC is on a distinguished road

Re: Re: Need some help on a C++ program for class

Code:
#include <iostream>
using namespace std;

int main()
{
	const double OUNCES_PER_TON = 35273.92;
	double ounces, tons, boxes;
	char loop;

***********************************************

do {		
	cout << "Enter the weight of ceral in ounces:\n";
	cin >> ounces;

	tons = ounces / OUNCES_PER_TON;
	cout << "The single box of cereal weighs " << tons << " metric tons." << endl << endl;

	if (tons == 1)
	{	
		cout << "You do not need any additional boxes of cereal." << endl;
		return 0;
	}
	
	else if(tons > 1)
	{
		cout << "You have exceeded 1 metric ton." << endl;
		return 0;
	}

	
	else (tons < 1);
	{		

		boxes = OUNCES_PER_TON / tons;
		cout << boxes << " boxes would be required to equal 1 metric ton." << endl;
	}

	cout << "/nCalculate Again? (y/n): ";
	cin >> loop;
}
while ( loop != 'n' );

return 0;

}
Should work, if not, um... oops

Code:
#include <iostream>
using namespace std;

int main()
{
	const double OUNCES_PER_TON = 35273.92;
	double ounces, tons, boxes;
	char loop;

***********************************************

while (true) {		
	cout << "Enter the weight of ceral in ounces:\n";
	cin >> ounces;

	tons = ounces / OUNCES_PER_TON;
	cout << "The single box of cereal weighs " << tons << " metric tons." << endl << endl;

	if (tons == 1)
	{	
		cout << "You do not need any additional boxes of cereal." << endl;
		return 0;
	}
	
	else if(tons > 1)
	{
		cout << "You have exceeded 1 metric ton." << endl;
		return 0;
	}

	
	else (tons < 1);
	{		

		boxes = OUNCES_PER_TON / tons;
		cout << boxes << " boxes would be required to equal 1 metric ton." << endl;
	}

	cout << "/nCalculate Again? (y/n): ";
	cin >> loop;

	if (loop == 'n') { break; }
}


return 0;

}
that should also work, but its inelegant.
__________________
[img][/img]
[color=White]Peace be with you, Joe.[/color]
Driverheaven Staff Member (Supermoderator)
ToshiroOC is offline   Reply With Quote
Old Sep 15, 2003, 05:58 AM Threadstarter Thread Starter   #11
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
I got it working before you posted this last one!!!!!! Thanks so much guys!!!!!!!!!!!!! Seriously, this sh|t stumps me. Thanks a lot Vampy and Tosh!!!!!!
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:00 AM   #12
Unbiased.
 
Join Date: Jun 2002
Posts: 4,812
Rep Power: 0
ToshiroOC is on a distinguished road

Bah, just after I thought of a second way to do it Oh well, not a problem, glad you got it working. Feel free to ask again later on.
__________________
[img][/img]
[color=White]Peace be with you, Joe.[/color]
Driverheaven Staff Member (Supermoderator)
ToshiroOC is offline   Reply With Quote
Old Sep 15, 2003, 06:01 AM   #13
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

np
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 06:05 AM Threadstarter Thread Starter   #14
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
PROBLEM!!!!!!!!! Look at this code..... When I make the value 35273.92 or greater than 35273.92 it runs through and tells me that I need more boxes (when I shouldn't)........... what's up with that.....?

Code:
#include <iostream>
using namespace std;
int main()

{
int answer;
	do
	{
	
{
	
	const double OUNCES_PER_TON = 35273.92;
	double ounces, tons, boxes;
			
		cout << "Enter the weight of cereal in ounces:\n";
		cin >> ounces;

		tons = ounces / OUNCES_PER_TON;
		cout << "The single box of cereal weighs " << tons << " metric tons." << endl << endl;

	if (tons == 1)
	{	
		cout << "You do not need any additional boxes of cereal." << endl;
		return 0;
	}
	
	else if(tons > 1)
	{
		cout << "You have exceeded 1 metric ton." << endl;
	}

	
	else (tons < 1);
	{		
		boxes = OUNCES_PER_TON / tons;
		cout << boxes << " boxes would be required to equal 1 metric ton." << endl;
	}
}	
		
		cout << "Do you want to repeat?\n"
			<< "Press 1 for YES or 2 for NO.\n";
		cin >> answer;
	} while (answer == 1);

	cout  << "Later!!!\n";

	return 0;
}


What I mean is that it runs the ELSE statement, when it shouldn't be......
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:09 AM   #15
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

I think that happens when you use a double in a == comparison
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 06:10 AM Threadstarter Thread Starter   #16
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
Do I should change it to an it?
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:10 AM   #17
Unbiased.
 
Join Date: Jun 2002
Posts: 4,812
Rep Power: 0
ToshiroOC is on a distinguished road

Make that last else statement an elseif, and put OUNCES_PER_TON / tons in parenthesis; not sure if either of those will fix it, I'm too lazy to compile it for myself to see, and the latter is only cosmetic, but *shrug* do it and tell me if it helps.

EDIT: instead of a double, do the following:

const float OUNCES_PER_TON = 35273.92F;
__________________
[img][/img]
[color=White]Peace be with you, Joe.[/color]
Driverheaven Staff Member (Supermoderator)
ToshiroOC is offline   Reply With Quote
Old Sep 15, 2003, 06:13 AM   #18
Zeeky H. Bomb
 
brc64's Avatar
 
Join Date: May 2002
Location: Evansville, IN
Posts: 826
Rep Power: 0
brc64 is on a distinguished road

Does your tons < 1 case work? It's been a while since I took C++, but that looks weird to me. I don't think I've ever seen an else statement with an evaluation after it before.. and the semicolon makes it look like it won't run the code in the braces. Of course, I suppose it's entirely possible that this is just an alternative way of doing an if/else than what I learned in school.. I dunno.

- Me
brc64 is offline   Reply With Quote
Old Sep 15, 2003, 06:14 AM   #19
Unbiased.
 
Join Date: Jun 2002
Posts: 4,812
Rep Power: 0
ToshiroOC is on a distinguished road

Quote:
Originally posted by brc64
Does your tons < 1 case work? It's been a while since I took C++, but that looks weird to me. I don't think I've ever seen an else statement with an evaluation after it before.. and the semicolon makes it look like it won't run the code in the braces. Of course, I suppose it's entirely possible that this is just an alternative way of doing an if/else than what I learned in school.. I dunno.

- Me
Oh, good catch, get rid of that semicolon in the last else, too.
__________________
[img][/img]
[color=White]Peace be with you, Joe.[/color]
Driverheaven Staff Member (Supermoderator)
ToshiroOC is offline   Reply With Quote
Old Sep 15, 2003, 06:16 AM   #20
Zeeky H. Bomb
 
brc64's Avatar
 
Join Date: May 2002
Location: Evansville, IN
Posts: 826
Rep Power: 0
brc64 is on a distinguished road

This is the most action this particular forum has seen in a while.

- Me
brc64 is offline   Reply With Quote
Old Sep 15, 2003, 06:16 AM Threadstarter Thread Starter   #21
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
Quote:
Originally posted by ToshiroOC
Oh, good catch, get rid of that semicolon in the last else, too.
Can't, won't run without that semi colon......
And no matter what i enter i still get that ELSE statement showing up...
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:16 AM   #22
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

Lol I didn't see that. Also, your variables should come before the "do"

EDIT ... you changed the else to else if?
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 06:19 AM Threadstarter Thread Starter   #23
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
here is the current program......... it runs, but it just slaps that last else statement in there no matter what i do.....

Code:
#include <iostream>
using namespace std;
int main()

{
int answer;

	const float OUNCES_PER_TON = 35273.92F;
	double ounces, tons, boxes;

	do
	{
	
{			
		cout << "Enter the weight of cereal in ounces:\n";
		cin >> ounces;

		tons = ounces / OUNCES_PER_TON;
		cout << "The single box of cereal weighs " << tons << " metric tons." << endl << endl;

	if (tons == 1)
	{	
		cout << "You do not need any additional boxes of cereal." << endl;
	}
	
	else if(tons > 1)
	{
		cout << "You have exceeded 1 metric ton." << endl;
	}

	
	else (tons < 1);
	{		
		boxes = (OUNCES_PER_TON / tons);
		cout << boxes << " boxes would be required to equal 1 metric ton." << endl;
	}
}	
		
		cout << "Do you want to repeat?\n"
			<< "Press 1 for YES or 2 for NO.\n";
		cin >> answer;
	} while (answer == 1);

	cout  << "Later!!!\n";

	return 0;
}
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:22 AM   #24
Zeeky H. Bomb
 
brc64's Avatar
 
Join Date: May 2002
Location: Evansville, IN
Posts: 826
Rep Power: 0
brc64 is on a distinguished road

Try this for your last test:
Code:
else
	{		
		boxes = (OUNCES_PER_TON / tons);
		cout << boxes << " boxes would be required to equal 1 metric ton." << endl;
          }
brc64 is offline   Reply With Quote
Old Sep 15, 2003, 06:24 AM Threadstarter Thread Starter   #25
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
OK, that helped..... BUT my only problem now is that when I run the value 35273.92 it still prints the line saying how many boxes are needed.
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:27 AM   #26
Zeeky H. Bomb
 
brc64's Avatar
 
Join Date: May 2002
Location: Evansville, IN
Posts: 826
Rep Power: 0
brc64 is on a distinguished road

Quote:
Originally posted by DriveEuro
OK, that helped..... BUT my only problem now is that when I run the value 35273.92 it still prints the line saying how many boxes are needed.
Erm.. I'm not too sure, but I just noticed something in the last code you posted.

Code:
const float OUNCES_PER_TON = 35273.92F;
Is there supposed to be an F after the .92 in that number? Is that actually in your program?

- Me
brc64 is offline   Reply With Quote
Old Sep 15, 2003, 06:29 AM   #27
confutatis maledictis
 
Vampyromaniac's Avatar
 
Join Date: May 2002
Location: somewhere dark
Posts: 5,974
Rep Power: 77
Vampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really niceVampyromaniac is just really nice
System Specs

can you switch to ints and use 35274 for the number?

btw are you using visual c++ or something?
__________________
Digitalis 3.3
Athlon 64 3000 // ASUS K8V SE Deluxe // 1024MB PC3200 (2-2-2-10 1T)
ATI All-In-Wonder 9700 Pro // 20" Dell 2005FPW (DVI)
M-Audio Revo 7.1 + Philips Acoustic Edge // Klipsch ProMedia 2.1
320/16 Western Digital WD3200KS + 120/8 Seagate 7200.7
NEC ND-3550A 16x DVD±RW + Lite-On 52x24x CD-RW
Antec Sonata case // 480W Antec TruePower

personal bests || Aq'3: 46796 | 3D'01: 20461 | 3D'03: 6336 | 3D'05: 2677 | PC'04: 4605 | PC'02: 7691,9092,1250

Vampyromaniac is offline   Reply With Quote
Old Sep 15, 2003, 06:31 AM Threadstarter Thread Starter   #28
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
That F needs to be there, doesn't run without it........ The F is there cuz it's a float....

And the book shows 35273.92, my teacher wouldn't like 35274, i know it for a fact...
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:32 AM Threadstarter Thread Starter   #29
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
Visual C++, yes.
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Old Sep 15, 2003, 06:34 AM Threadstarter Thread Starter   #30
HardwareHeaven Extreme Member
 
Join Date: Jul 2002
Location: Gurnee Illinois
Posts: 4,677
Rep Power: 0
DriveEuro is on a distinguished road

Donator
OK, at this point..... X>35273.92 works........ X = 35273.92 doesn't work........ spits out the number of boxes needed...... X<35273.92 works......

Changing (ton == 1) to..... (ton = 1) messes everything up...
__________________
[color=orange]ASUS P4P800 Deluxe [color=black]-[/color] 2.4C --> 3300mhz [color=black]-[/color] Mushkin PC3200 at 220 5-2-2-2 (cpu limited) [color=black]-[/color] BBAti 9800Pro at 430/375 [/color]
[color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]01[/color] [color=black]3[/color][color=gray]D[/color]M[color=black]a[/color][color=gray]r[/color]k[color=yellow]03[/color] 1600*1200 1280*1024
DriveEuro is offline   Reply With Quote
Reply

Thread Tools