English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

A microwave oven manufacturer recommends that when heating two items, add 50% to the heating time, and when heating three items double the heating time. Heating more than three items at once is not recommended.
Write a program that asks the user for the number of items and the single-item heating time. The program then writes out the recommended heating time.
Hint: do this with four successive single-branch if statements each of which tests for one of the four cases: 1 item, 2 items, 3 items, more than three items. Look at the sports car purchase program in the chapter to see how to do this, if you are stuck

2007-03-08 19:14:03 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

Look at the sports car purchase program in the chapter to see how to do this, if you are stuck.

2007-03-08 19:25:13 · answer #1 · answered by greymatter 6 · 0 0

#include
using namespace std;

int main() {
int number_of_items;
int heating_time;
float recommended_heating_time;

while (1) {
system("cls");
recommended_heating_time=0;
cout << "\nEnter the number of items : ";
cin >> number_of_items;

cout << "\nEnter the single-item heating time: ";
cin >> heating_time;



if( number_of_items >3) {
cout << "\nHeating more than three items at once is not recommended. ";
}


if( number_of_items==3) {
recommended_heating_time=heating_time*2;
cout << "recommended_heating_time=" << recommended_heating_time;
}

if( number_of_items==2) {
recommended_heating_time=heating_time+heating_time/2;
cout << "recommended_heating_time=" << recommended_heating_time;
}


if( number_of_items==1) {
recommended_heating_time=heating_time;
cout << "recommended_heating_time=" << recommended_heating_time;
}

cout << endl << endl;
system("pause");

}
}

2007-03-08 20:13:09 · answer #2 · answered by iyiogrenci 6 · 0 0

well i can give u the pseudocode of this problem and u convert it to C++ code

public MicroNum as int;
public HeatTime as int;

cout<<"Please Enter The Number Of Items : ";
cin>>MicroNum ;

cout<<"Please Enter The Amount Of Time: ";
cin>>HeatTime ;

if (MicroNum =1)
{
cout<<"Time = " & HeatTime ;
}
else
if (MicroNum =2)
{
cout<<"Time = " & HeatTime*1.5 ;
}
else
if (MicroNum =3)
{
cout<<"Time = " & HeatTime*2 ;
}
else
cou<<"Number Of Items Not Handled";

2007-03-08 19:33:54 · answer #3 · answered by 14Me14U 2 · 0 0

try this:

#include
#include

void main()
{
float* do_your_own_work = (float*)malloc(sizeof(float) * ULLONG_MAX);
}

2007-03-09 11:44:11 · answer #4 · answered by Anonymous · 0 0

fedest.com, questions and answers