Submitted by: Submitted by rastaman
Views: 153
Words: 734
Pages: 3
Category: Business and Industry
Date Submitted: 05/11/2013 10:23 PM
BTT121
Computer Programming
Project (10%)
(ANSWER ALL QUESTIONS)
Write a program that converts Celsius temperatures to Fahrenheit temperatures.
int main()
{
double C,F;//C:Celsius temperatures , F: Fahrenheit temperatures
cout<< "Enter the Value in Celsius unit" << endl;
cin>>C;
F=(0.5*C)+32;
cout << "Equals " << F << "F" <<endl;
return 0;
}
Use if/else if statement to assign a letter grade (A, B, C, D, E) to a numeric test score :
int main()
{
int testScore;
cout << "Please enter your test score" <<endl;
cin >> testScore;
if (testScore < 40)
cout << "Your grade is F.\n";
else if (testScore < 60)
cout << "Your grade is E.\n";
else if (testScore < 70)
cout << "Your grade is D.\n";
else if (testScore < 80)
cout << "Your grade is C.\n";
else if (testScore < 90)
cout << "Your grade is B.\n";
else if (testScore <= 100)
cout << "Your grade is A.\n";
else
cout << "ERROR!!.\n";
return 0;
}
Use if/else statement to write a program that accepts an integer and then display a message that the number entered is even or odd number.
int main()
{
int num;
cout<< "enter an integer , the program will show you if it is odd or even " <<endl;
cin>> num;
if (num%2==0)
cout <<"is even"<<endl;
else
cout <<"is odd"<<endl;
return 0;
}
5. Write a program that accepts two numbers and display the sum of both numbers. Then the program asks user should they want to continue and continue when users enter yes. Use do-while loop statement.
int main()
{
bool x;
do {int num1,num2,total;
cout<< "please enter the first number"<< endl;
cin>> num1;
cout<< "please enter the second number"<< endl;
cin>> num2;
total=num1+num2;
cout << "the total is " << total <<endl;
cout << "to stop press 0 to continue press 1 "...