Hi everone,
Today i have a question has two parts and i did what i undrstood.If threr are mistakes ,please tell me.

The Question is:

father decided to buy a new vehicle. He paid 20,000 QR in cash and the rest will be paid on settlements as follows:
 1500 QR per month for 12 months.
 800 QR per month for 24 months, and
 600 QR per month for 48 months.
Q1: Write a C++ program that asks the user to enter the number of months he wants and calculates the total price of the car.
Q2: Adjust the program so that it gives your father a discount on the total price of the car as follows:
 If the total price of the car is less than 38,500 QR the discount will be 15%.
 If the total price of the car is between 36,500 QR and 40,000 QR the discount will be 17%.

 If the total price of the car exceeds 40,000 QR the discount will be 17%.
The program should give now the total price of the car before and after the discount

My answer is :

#include <iostream>
#include<cmath>
using namespace std;
int main(){
	int month ;
	double price;
	cout<<"Enetre your month "; \\the month has to be 12,24 or 48  
	cin>>month ;
	if (month ==12)  
	   cout<<"Total price is= "<<(1500*12)+20000=";  \\total price for 12 months
	else if (month  ==24)
	   cout<<"Total price is= "<<(800*24)+20000="; \\total price for 24 months
	else if (month ==48)
	   cout<<"Total price is= "<<(600*48)+20000="; \\total price for 48 months
	else 
	    cout<<"Writhe another month";\\user enter no on of th three months


           


 return 0;
}

2 )
#include <iostream>
#include<cmath>
using namespace std;
int main(){
	int month ,total,afterdiscount;
	double price;
	cout<<"Enetre your month ";
	cin>>month ;
	if (month ==12)
	   total= (1500*12)+20000;
	else if (month  ==24)
	  total<<(800*24)+20000=";
	else if (month ==48)
	   total<<(600*48)+20000=";
	else 
	    cout<<"Writhe another month";
	if (total <38500)
	    afterdiscount=total*0.85;
	else if (total>40000)
	    afterdiscount=total*0.83;
	else 
	     afterdiscount=total*0.83;
	  
	   


           


 return 0;
}

>>cout<<"Total price is= "<<(1500*12)+20000=";
remove the quote just before the semicolon. same problem on all the other lines in the 1st program

Yeh, i agree remove that line, but even if you did, multiplication is read before addition, so no need for brackets, if i am correct?

>>Yeh, i agree remove that line
I didn't say that.

Maybe not, but I use them anyway just for clarity -- you don't have to think about it very much.

Sorry i meant quote,

Thanks . Is that mean i had one mistake"quote"only.
Thanks again..

Yes only 1 mistake.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.