C++ Program # 2 Folder: CPT 180 File Name: CPP-Project2.docx Project Number 2 [a
ID: 3710790 • Letter: C
Question
C++ Program # 2
Folder: CPT 180
File Name: CPP-Project2.docx
Project Number 2 [after chapter 4]
1} Place this statement after the other import statement in your code
“#include <iostream>”
2) Define an integer named choice.
3) Use a System.out.println to print out a menu of this sort to the user
“This program provides the following capabilities
it will convert Celsius temperature to its corresponding Fahrenheit temperature
it will convert a distance of centimeters to its corresponding value in inches.
It will convert an angle measurement from radians to degrees
It will convert Liters to Quarts
Enter 1 for Celsius to Fahrenheit
Enter 2 for centimeters to inches
Enter 3 for radians to degrees
Enter 4 for liters to quarts
4) cin >> choice;
choice = keyboard.nextInt();
5) Test to make sure only a 1, 2 or 3 are entered i.e
If choice < 1 || choice 4{
cout << “Incorrect entry, please enter 1 , 2 , 3 or 4”;
cin >>choice;
}
6) Use an if statement to test choice for a value of 1, and then execute the code for the temperature conversion.
7) Use an if statement to test choice for a value of 2, and then execute the code for the conversion of cm to in.
8) Use an if statement to test choice for a value of 3, then execute the code for the conversion of radians to degrees
9) Use an if statement to test choice for a value of 4, then execute the code for the conversion of liters to quarts
10) Leave the exit statement outside the 4 if statement blocks of code.
Faherheit=(9.0/5.0)*Celsius + 32.0
Centimeters= 2.54 times inches
Inches= centimeters divided by 2.54
degrees= radians times 180 divided by 3.14159
Explanation / Answer
Solution:
Note: The first four subparts have been answered as per Chegg guidelines, please repost others.
Note: The requirement doesn't seem to be quite clear, I have solved based on my understanding of the question, please comment in case of any difference
1)
import package.chegg;
#include <iostream>
2)
int choice;
3)
System.out.println("Enter 1 for Celsius to Fahrenheit");
System.out.println("Enter 2 for centimeters to inches");
System.out.println("Enter 3 for radians to degrees");
System.out.println("Enter 4 for liters to quarts");
In c++:
cout<<"Enter 1 for Celsius to Fahrenheit";
cout<<"Enter 2 for centimeters to inches";
cout<<"Enter 3 for radians to degrees";
cout<<"Enter 4 for liters to quarts";
4)
cin >> choice;
choice = keyboard.nextInt();
5)
If (choice < 1 || choice 4){
cout << “Incorrect entry, please enter 1 , 2 , 3 or 4”;
cin >>choice;
}
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.