Jump to content

I need help with c++ and code blocks

ILLUMINATY

Im trying to create a calculator that would calculate the area of a rooms floor and how much would it cost to replace it with a new one.

CurrentlyImtuck on line 7. What in the wourld is an initializer??? I need one before int in line 7.

 

 

1 //Price calculator

2 #include <iostream>

3 using namespace std;

4 int main ()

5

6 {int a,b

int S; // area of the rooms floor 

double m2 price // price of 1 square meter of tiles

double Mamount // amount of money 

10 cout << a * b << endl;

11  cout << "dial in the length of the room"; cin >> a;

12 cout << "dial in the widht of the room"; cin >> b;

13 cout << S = a * b;

14 cout << "the area of the rooms floor": << S << endl;

15 cout << "dial in the price of 1 square meter of tiles":;

16 cin >> m2 price;

17 Psuma = 1,05 * S * << m2 price >>;

18 cout << "the amount of money you need to pay": << Mamount << endl;

19 cout << "Calculation is complete" << endl;

 20 return 0;

}

Link to comment
Share on other sites

Link to post
Share on other sites

Line 6 forgot a semi colon. 

 

Edit several lines are missing semi colons.

 

edut edit 

line 8 is either missing a comma or you don’t know that variables cannot have spaces in them. 

Link to comment
Share on other sites

Link to post
Share on other sites

I would recommend using an IDE to help catch syntax errors, also you can use the code tool in this forum to show code in a more readable way

 

a la:

//Price calculator

#include <iostream>

using namespace std;

int main ()
{
    int a,b
    int S; // area of the rooms floor 
    double m2 price // price of 1 square meter of tiles
    double Mamount // amount of money 
    cout << a * b << endl;
    cout << "dial in the length of the room"; cin >> a;
    cout << "dial in the widht of the room"; cin >> b;
    cout << S = a * b;
    cout << "the area of the rooms floor": << S << endl;
    cout << "dial in the price of 1 square meter of tiles":;
    cin >> m2 price;
    Psuma = 1,05 * S * << m2 price >>;
    cout << "the amount of money you need to pay": << Mamount << endl;
    cout << "Calculation is complete" << endl;
    return 0;
}

(note I didn't change any actual code, those issues @fpo mentioned are still there)

 

also, where is Psuma declared?

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

//Price calculator

#include <iostream>

using namespace std;

int main ()
{
    int a,b // why integers for a,b and S??
    int S;  
    double m2 price // you have to use an underline "_" to declare that variable, otherwise your compiler throws an error.
    double Mamount  
    cout << a * b << endl; // not sure if you wanted to get this line printed, if so you have to use "".
    cout << "dial in the length of the room"; cin >> a;
    cout << "dial in the widht of the room"; cin >> b;
    cout << S = a * b; // source of error. in this line you want to give out and assign at the same time.
    cout << "the area of the rooms floor": << S << endl;
    cout << "dial in the price of 1 square meter of tiles":; // here you have to use the : inside the ".
    cin >> m2 price;
    Psuma = 1,05 * S * << m2 price >>; //????
    cout << "the amount of money you need to pay": << Mamount << endl;
    cout << "Calculation is complete" << endl;
    return 0;
}
#include <iostream>

using namespace std;

int main()
{
    double a,b,m2_price,Mamount,S; //double, if the room measurements are not whole numbers.
    
    cout << "a * b" << endl; //still not sure, if you realy want/need this line.
    cout << "dail in the length of the room" << endl; cin >> a;
    cout << "dail in the width of the room" << endl; cin >> b;
    S = a*b;
    cout << "the area of the rooms floor: " << S << endl;
    cout << "dail in the price of 1 sqare meter of tiles: " << endl; cin >> m2_price;
    Mamount = 1.05 * S * m2_price;
    cout << "the amount of money you need to pay: " << Mamount << endl;
    cout << "Calculation is complete" << endl;
    
    return 0;
  
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×