Need Help, Not sure what I'm doing wrong

I have to write a program for class and i have everything done but get an error on the very last line and i'm not really sure why. Here is what i have so far.

#include <iostream>


using namespace std;

int main()
{
int num1 = 0;
int num2 = 0;
{
cout << "Enter Two Numbers To Compare " << endl;
cin >> num1 >> num2;
if (num1<num2)
{
cout << num2 << " is the larger number" << num1 << " and " << num2 << " is the smallest number" << endl;
}
else if (num1>num2)
{
cout << num1 << " is the larger number" << num2 << " and " << num1 << " is the smallest number" << endl;
}
system ("PAUSE");
return 0;
} <------this is where i'm getting the error when i try to compile it
Count your brackets.
This brace is excess

int num1 = 0;
int num2 = 0;
{

Also your program say nothing if the two numbers are equal.:)
Thanks got it to run but now i'm not getting the output i need but atleast its working. He didn't say anything about if it equaled just which is larger but i will try and figure that one out as well.

output:
Enter two numbers to compare
1
5
5 is the larger number1 and 5 is the smallest number

#include <iostream>


using namespace std;

int main()
{
int num1 = 0;
int num2 = 0;

cout << "Enter Two Numbers To Compare " << endl;
cin >> num1 >> num2;
if (num1<num2)
{
cout << num2 << " is the larger number" << num1 << " and " << num2 << " is the smallest number" << endl;
}
else if (num1>num2)
{

cout << num1 << " is the larger number" << num2 << " and " << num1 << " is the smallest number" << endl;
}
system ("PAUSE");
return 0;
}
I need to display which number is larger and which number is smaller. And i am very much a begginer at this.
Replace this code

if (num1<num2)
{
cout << num2 << " is the larger number" << num1 << " and " << num2 << " is the smallest number" << endl;
}
else if (num1>num2)
{

cout << num1 << " is the larger number" << num2 << " and " << num1 << " is the smallest number" << endl;
}

with this one

if (num1<num2)
{
cout << num2 << " is the larger number" << " and " << num1 << " is the smallest number" << endl;
}
else if (num1>num2)
{

cout << num1 << " is the larger number" << " and " << num2 << " is the smallest number" << endl;
}
ahhhh, i see what i did now. Thank you very much for the help. Now on to the second one.
Project 2 was create a program that will accept a number as input and output whether the number is even or odd. Got it to work just want to make sure it all looks right. Thanks

using namespace std;

int main(int argc, char *argv[])
{

int num;

cout << " Enter number to evaluate " << endl;
cin >> num;
if (num%2==0)
{
cout << num << " is an even number" << endl;
}
else
{
cout << num << " is an odd number" << endl;
}

system("PAUSE");
return EXIT_SUCCESS;
}
Project 3 i'm completely lost
Given the approriate dimensions (ft) to a room and a cost of flooring per square foot, output the total cost of the flooring. The room can be rectangular or circular. the program should hand either case.
Can you tell me how this looks so far?

#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
int choice = 0
double lenght, width, area, costPerSqFt;

cout << Select 1 for rectangle and 2 for a cirle: "
cin >> choice;

if (choice == 1)
{
cout << "Enter the lenght" << endl;
cout << "Enter the width" << endl;
cout << "Enter the costPerSqFt" << endl;

Total Cost = (lenght*width*costPerSqFt)
}

if (Choice == 2)
{
cout << "Enter area of circle" << endl;
cout << "Enter the diamter of the circle" << endl;

Total Cost = (area*diameter=2r*3.1416)

}

cout << "The cost is $" endl:

system("PAUSE");
return EXIT_SUCCESS;
}

1
2
3
4
5
6
7
8
if (choice == 1)
{
cout << "Enter the lenght" << endl;
cout << "Enter the width" << endl;
cout << "Enter the costPerSqFt" << endl;

Total Cost = (lenght*width*costPerSqFt) // what values are currently stored inside of lenght, width, and costPerSqFt?
}
Not sure, i'm kinda confused on this one. I started over and this is what i have now but i'm getting stuck on the What is the cost per sq ft line

using namespace std;

int main()
{

int choice = 0;
double rectagular(double cost);
double circular (double cost);

cout << "Flooring Tool!" << endl;
cout << "______________" << endl;

cout << "Enter 1 for rectangular and 2 for circular" << endl;
cin >> choice;
}
cout << "What is the cost of flooring per sq ft" << endl;
cin >> cost;

if (choice == 1)
totalCost = rectangular(cost);
else
totalCost = circular(cost);
cout << fixed << setprecision(2) << "Total cost of Flooring is $" << totalCost << endl;

system("PAUSE");
return EXIT_SUCCESS;
}

i'm lost, i'm to new to this and don't think i'm going to be able to get it done. I know it has to be something simple that i am missing and just can't figure it out.
#include <cstdlib>
#include <iostream>
double rectangular(double cost);
double circular(double cost);
using namespace std;

int main()
{
int choice = 0;
double cost, totalCost;
while(choice !=1 && choice!=2){
cout << "1. Rectangual Room" <<endl;
cout << "2. Circular Room" <<endl;
cin >> choice;
}
cout << "What is the cost of flooring per sq ft?: ";
cin>> cost;

if (choice == 1)
totalCost = rectangular(cost);
else
totalCost = circular(cost);
cout << fixed << setprecision(2) << "Total cost of Flooring is: $" << totalCost <<endl; <--this is where i'm getting my problem at
return 0;
}

double rectangular(double cost){
double x,y;

cout << "First dimension(ft): ";
cin >> x;
cout << "Second dimension(ft): ";
cin >> y;
return x*y*cost;
}
double circular(double cost){
double r;

cout << "Enter room radius(ft): ";
cin >> r;
return r*r*PI;
}

Last edited on
Okay, can you describe your problem? Does your compiler give you an error?
Hey Cambycis
it's working fine in my PC.
Last edited on
Topic archived. No new replies allowed.