|
  
|
|
|||||||
| Tech. help Come here for help with technology related problems. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | |
|
The Ragin` Cajun
Support Team
Jr. Staff Zune Freak |
Quote:
Here's what I have so far; Code:
// Beginning of Soft Drinks Program
#include<iomanip>
#include <iostream>
using namespace std;
int main()
{
// Variable Declarations
int customers = 12467, purchased = 1745, citrus = 7978;
// Display Soft Drink Information
cout << " Of the " << customers << " that we have surveyedn ";
cout << " We have found that " << purchased << " have purchased one or more energy drinks per week.n ";
cout << " While " << citrus << " prefer to only purchase citrus flavored energy drinks ";
return 0;
}
What I have will Compile but it won't Run ![]() Last edited by Carlos : 09-25-2008 at 02:12 PM. |
|
|
|
|
|
|
#2 (permalink) |
|
you lost the game.
zB Programmer
Section Staff Zune Freak Join Date: May 2008
Posts: 1,211
Reputation: 451
|
The code looks like it should work, though you should probably be doing the math in the program, like this:
Code:
int n = foo; float purchasers = bar; float citrus = baz; cout << "Respondents: " << n << endl; cout << "Respondents who purchase energy drinks: " << (int)(n * purchasers) << endl; cout << "Respondents who prefer citrus: " << (int)(n * citrus * purchasers) << endl;
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. signature by To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
#3 (permalink) | |
|
The Ragin` Cajun
Support Team
Jr. Staff Zune Freak |
Quote:
Code:
// Beginning of Soft Drinks Program
#include<iomanip>
#include <iostream>
using namespace std;
int main()
{
// Variable Declarations
int n = 12467;
float purchasers = 1745;
float citrus = 7989;
// Display Soft Drink Information
cout << "Respondents: " << n << endl;
cout << "Respondents who purchase energy drinks: " << (int)(n * purchasers) << endl;
cout << "Respondents who prefer citrus: " << (int)(n * citrus * purchasers) << endl;
return 0;
}
Could it be because of my Compiler? I'm using Bloodshed Dev C++. |
|
|
|
|
|
|
#4 (permalink) | |
|
you lost the game.
zB Programmer
Section Staff Zune Freak Join Date: May 2008
Posts: 1,211
Reputation: 451
|
Quote:
Code:
cin.ignore();
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. signature by To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
|
#6 (permalink) | |
|
The Ragin` Cajun
Support Team
Jr. Staff Zune Freak |
Alright here's another one that's been giving me trouble;
Quote:
Code:
// Begin Min Max Program
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Declare Variables
float Numbers;
float Number_One;
float Number_Two;
// Input Information
cout << " Enter Your Numbers : ";
cin >> Number_One >> Number_Two;
Numbers = (Number_Two==Number_One) ? 0 : Number_One; // Conditional Operator
cout << Number_Two << " is larger than " << Number_One << endl;
cout << Number_One << " is smaller than " << Number_Two << endl;
system("PAUSE");
return 0;
}
9 is larger than 2 2 is smaller than 9 If I put in 2 9. But if I use 9 2 it says 2 is larger than 9 9 is smaller than 2 Last edited by Carlos : 09-25-2008 at 07:40 PM. |
|
|
|
|
|
|
#7 (permalink) | |
|
you lost the game.
zB Programmer
Section Staff Zune Freak Join Date: May 2008
Posts: 1,211
Reputation: 451
|
Quote:
Code:
if (Number_One == Number_Two)
{
cout << Number_One << " is equal to " << Number_Two << endl;
}
else
{
float greater = (Number_One > Number_Two) ? Number_One : Number_Two;
float lesser = (Number_One < Number_Two) ? Number_One : Number_Two;
cout << greater << " is greater than " << lesser << endl;
cout << lesser << " is less than " << greater << endl;
}
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. signature by To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
|
#8 (permalink) | |
|
The Ragin` Cajun
Support Team
Jr. Staff Zune Freak |
Quote:
So it should read as; Code:
// Begin Min Max Program
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Declare Variables
float Numbers;
float Number_One;
float Number_Two;
// Input Information
if (Number_One == Number_Two)
{
cout << Number_One << " is equal to " << Number_Two << endl;
}
else
{
float greater = (Number_One > Number_Two) ? Number_One : Number_Two;
float lesser = (Number_One < Number_Two) ? Number_One : Number_Two;
cout << greater << " is greater than " << lesser << endl;
cout << lesser << " is less than " << greater << endl;
}
The last } is giving me an error though @_@ |
|
|
|
|
|
|
#9 (permalink) | |
|
you lost the game.
zB Programmer
Section Staff Zune Freak Join Date: May 2008
Posts: 1,211
Reputation: 451
|
Quote:
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. signature by To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. ![]() |
|
|
|
|
|
|
#10 (permalink) |
|
The Ragin` Cajun
Support Team
Jr. Staff Zune Freak |
Yeah I got that part, however it seems to be adding in random numbers (or at least something).
It should allow the user to put in 2 random numbers (I.E 2 9), thus listing; 2 is smaller than 9 9 is larger than 2 and possibly vice versa (I.E 9 2). |
|
|
|
|
|
#12 (permalink) | |
|
The Ragin` Cajun
Support Team
Jr. Staff Zune Freak |
Alright here's a new one;
Quote:
Code:
#include <iostream>
using namespace std;
int main()
{
// Declare Constants
float number
float numTwenty;
float numFourty;
float numSixty;
float numEighty;
float numHundred;
// Initiate the Variables
cout << "Please Enter 5 Integers In The Range Of 1 - 99: ";
cin >> numTwenty >> numFourty >> numSixty >> numEighty >> numHundred;
do
{
while (number > 50 || number < 50)
cout
I know what I have so far doesn't work, but I just want to know. ======= Now that I look at it more, wouldn't a 'For' Loop with Increment and Decrement Operators work as well? Maybe so. We'll see. Last edited by Carlos : 10-15-2008 at 09:25 AM. |
|
|
|
|
|
|
#13 (permalink) | |
|
God of the Post Reports
Support Team
Section Staff Super Zuner² |
This is what I've gotten:
Code:
#include <iostream>
using namespace std;
int main()
{
int input, sum(0), driver(1);
cout << "Please Enter Integers In The Range Of 1 - 99: (Enter -99 to stop)" << endl;
while(driver == 1)
{
cin >> input;
if (input > 99 || input < 1)
{
cout << "Please enter valid input: (1-99) << endl;
cin >> input;
}
if(input == -99)
break;
else
{
sum += input;
}
}
cout << "The sum of the integers entered is: " << sum << endl;
return 0;
}
EDIT: Shoot, forgot about the 1-99 limit; I'll add it.
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. Now with links! Quote:
Last edited by Locke : 10-15-2008 at 10:20 AM. ![]() |
|
|
|
|
|
|
#14 (permalink) | |
|
ad majorem dei gloriam
Administrator
Ultimate Zuner Join Date: Jan 2007
Posts: 6,600
Reputation: 474
|
Quote:
you==fail w/ = edit: break=lame
__________________
To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. is awesome Last edited by Deiparous : 10-15-2008 at 10:05 AM. |
|
|
|
|