Caringal - CODE
Caringal - CODE
#include<iostream>
using namespace std;
int main(){
char choice;
double celcius, fahrenheit;
bool ans = false;
do{
cout<<"=====Temperature Conversion====="<<endl;
cout<<"A. Celsius to Fahrenheit"<<endl;
cout<<"B. Fahrenheit to Celsius"<<endl;
cout<<"Enter choice: ";
cin>>choice;
switch(choice){
case 'A':
cout<<"Enter temperature in Celsius: ";
cin>>celcius;
fahrenheit = (9.0/5.0) * celcius + 32;
case 'B':
cout<<"Enter temperature in Fahrenheit: ";
cin>>fahrenheit;
default:
cout<<"Invalid choice!!!";
cout<<endl<<endl;
break;
}
}while(ans==false);
return 0;
}
2. Create a program that will produce this output: Enter three
numbers: First number: 10 Second number: 20 Third number: 55 The
largest number is
#include<iostream>
int main(){
int num1, num2, num3;
return 0;
}
Please use switch statement
1. Create a C++ program that will produce this output:
Enter a radius: __
=====Circle Computation=====
A. Compute Area
B. Compute Diameter
C. Compute Circumference
Enter choice: _
If the choice is A, it will display the area of a circle;
If the choice is B, it will display the diameter of a circle;
If the choice is C, it will display the circumference of a circle;
If you entered a choice that is not among the options it will display
INVALID CHOICE!!!
#include<iostream>
int main(){
char choice;
float PI = 3.141;
double radius, area, diameter, circumference;
bool ans = false;
do{
cout<<"=====Circle Computation====="<<endl;
cout<<"A. Compute Area"<<endl;
cout<<"B. Compute Diameter"<<endl;
cout<<"C. Compute Circumference"<<endl;
switch(choice){
case 'A':
area = PI * radius * radius;
cout<<"Area of a circle is: "<<area<<endl<<endl;
break;
case 'B':
diameter = 2 * radius;
cout<<"Diameter of a circle is:
"<<diameter<<endl<<endl;
break;
case 'C':
circumference = 2 * PI * radius;
cout<<"Circumference of a circle is:
"<<circumference<<endl<<endl;
break;
default:
cout<<"INVALID CHOICE!!!"<<endl<<endl;
}
}while(ans==false);
return 0;
}