Keep getting same results.

I'm a little confused about structuring the code. Keep getting the same output. It's supposed to be a program that lets you choose the watch you want to buy and then calculates the final price of the selected watch. You press 1 for a Bulova watch, 2 for a Omega watch and 3 for a Rolex. Problem is the program gives me the bulova final price as an output no matter what number I press. On top of that I get an error that I can't figure out. Can some one give me some assistance?


#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()

{
//declarar variables
int menu = 0;
double descuento = 0.0;
double precioDescontado = 0.0;
double ivuEst = 0.0;
double ivuMun = 0.0;
double totalIvu = 0.0;
double precioFinal = 0.0;

//entrar data
cout << "Para obtener precio oprima el numero que corresponde a las marcas siguientes: ";
cout << endl;
cout << endl;
cout << "Para Bulova oprima 1.";
cout << endl;
cout << endl;
cout << "Para Omega oprima 2.";
cout << endl;
cout << endl;
cout << "Para Rolex oprima 3.";
cout << endl;
cin >> menu;
cout << menu;

//proceso



if (menu = 1){

descuento = 350 * .10;

precioDescontado = 350 - descuento;

ivuEst = precioDescontado * .05;

ivuMun = precioDescontado * .02;

totalIvu = ivuEst + ivuMun;

precioFinal = precioDescontado - totalIvu;

cout << "Nombre del reloj: Bulova" << endl;
cout << endl;
cout << "Precio basico: $350" << endl;
cout << endl;
cout << "Descuento de 10%: $" << descuento << endl;
cout << endl;
cout << "Precio despues del descuento: $" << precioDescontado << endl;
cout << endl;
cout << "IVU estatal (5%): $" << ivuEst << " + IVU municipal (2%): $" << ivuMun << " = Total IVU = $" << totalIvu << endl;
cout << endl;
cout << "Precio de venta final: $" << precioFinal << endl;
}
else{
if (menu = 2){

descuento = 500 * .10;

precioDescontado = 500 - descuento;

ivuEst = precioDescontado * .05;

ivuMun = precioDescontado * .02;

totalIvu = ivuEst + ivuMun;

precioFinal = precioDescontado - totalIvu;

cout << "Nombre del reloj: Omega" << endl;
cout << endl;
cout << "Precio basico: $500" << endl;
cout << endl;
cout << "Descuento de 10%: $" << descuento << endl;
cout << endl;
cout << "Precio despues del descuento: $" << precioDescontado << endl;
cout << endl;
cout << "IVU estatal (5%): $" << ivuEst << " + IVU municipal (2%): $" << ivuMun << " = Total IVU = $" << totalIvu << endl;
cout << endl;
cout << "Precio de venta final: $" << precioFinal << endl;
}

else{
if (menu = 3){

descuento = 3322 * .10;

precioDescontado = 3322 - descuento;

ivuEst = precioDescontado * .05;

ivuMun = precioDescontado * .02;

totalIvu = ivuEst + ivuMun;

precioFinal = precioDescontado - totalIvu;

cout << "Nombre del reloj: Rolex" << endl;
cout << endl;
cout << "Precio basico: $3322" << endl;
cout << endl;
cout << "Descuento de 10%: $" << descuento << endl;
cout << endl;
cout << "Precio despues del descuento: $" << precioDescontado << endl;
cout << endl;
cout << "IVU estatal (5%): $" << ivuEst << " + IVU municipal (2%): $" << ivuMun << " = Total IVU = $" << totalIvu << endl;
cout << endl;
cout << "Precio de venta final: $" << precioFinal << endl;
}






return 0;

}
I think this:
 
if (menu = 1){

should probably be this:
 
if (menu == 1){

You need the double = to compare. Single = is for assignment.
Hmm, no it didn't work.

Error 1 fatal error C1075: end of file found before the left brace '{' at 'f:\cois 270\projects\examen 1a\examen 1a\relojes2.cpp(67)' was matched f:\cois 270\projects\examen 1a\examen 1a\relojes2.cpp 131 Examen 1a

What about this error. Can't seem to get rid of it.

I'm really stuck.
Look at what the error says: the file ended before the left brace '{' was matched

It's telling you that you forgot a '}' to close the block of logic that started with the '{' at line 67

If I could make a suggestion about your program.

1
2
3
4
5
6
7
if (menu == 1)
{
    watch = "Rolex";
    price = 50;
}
else
if (menu...


now use watch in your output, and use price as input to your maths to derive the different results for each choice, rather than repeating the calculation code block or each menu choice.

Also, look into switch statements rather than using if then else if then else if then else...

Yay! It worked. Thank you all. You've been a great help.
Topic archived. No new replies allowed.