# 3 quick questions

#### Solution

question1.cpp

#include

using namespace std;

// Entry point of the program

int main()

{

// Get number of students and teachers

cout<< “Input number of students: “;

intnumStudents;

cin>>numStudents;

cout<< “Input number of teachers: “;

intnumTeachers;

cin>>numTeachers;

// Calculate average

doubleaverageStudentsPerTeacher = numStudents / numTeachers;

// Output result

cout<< “Average Students per Teacher: ” <

return 0;

}

question5.cpp

#include

using namespace std;

// Entry point of the program

int main()

{

// Get number of sandwiches and ounces of meat per sandwich

cout<< “Input number of sandwiches: “;

intnumSandwiches;

cin>>numSandwiches;

cout<< “Input ounces of meat per sandwich: “;

doubleouncesPerSandwich;

cin>>ouncesPerSandwich;

// Calculate total ounces needed

doubletotalOunces = numSandwiches * ouncesPerSandwich;

// Calculate in pounds

doubleouncesInAPound = 16;

doublepoundsToPurchase = totalOunces / ouncesInAPound;

// Output result

cout<< “You will need to purchase ” <

return 0;

}

question8.cpp

#include

using namespace std;

// Entry point of the program

int main()

{

// Get dental charge

cout<< “How much is the dental charge: “;

doubledentalCharge;

cin>>dentalCharge;

// Calculate cost to pay by customer

doublecoPay = 20;

doublechargeLeft = dentalCharge – coPay;

doubleadditionalPay = chargeLeft * 0.15;

doublemyCost = coPay + additionalPay;

// Calculate cost by insurance

doubleinsuranceCost = dentalCharge – myCost;

// Output result

cout<< “You will pay $” <

return 0;

}

#### Question 1

IPO Chart

Input |
Process |
Output |

i.1 Number of students i.2 Number of teachers | p.1 Average students per teacher = Number of students / Number of teachers | o.1 Average students per teacher |

### Flow Chart

### Desk Check

### 1200 Students and 60 Teachers

IPO Reference |
Number of students |
Number of teachers |
Avg students per teacher |
Output |
Input |

i.1 | “Input number of students” | 1200 | |||

i.2 | 1200 | “Input number of teachers” | 60 | ||

p.1 | 1200 | 60 | 20 | ||

o.1 | 1200 | 60 | 20 | 20 |

### 2500 Students and 100 Teachers

IPO Reference |
Number of students |
Number of teachers |
Avg students per teacher |
Output |
Input |

i.1 | “Input number of students” | 2500 | |||

i.2 | 2500 | “Input number of teachers” | 100 | ||

p.1 | 2500 | 100 | 25 | ||

o.1 | 2500 | 100 | 25 | 25 |

### Question 5

### IPO

Input |
Process |
Output |

i.1 Number of sandwich i.2 Ounces of meat per sandwich | p.1 Ounces in a pound = 16 p.2 Total ounces = Number of sandwich * ounces of meat per sandwich p.3 Pounds to purchase = Total ounces / Ounces in a pound | o.1 Pounds to purchase |

#### Flow Chart

### Desk Check

### 50 Sandwich with 4 Ounce Meat Each

IPO Reference |
Ounces in a pound |
Number of sandwich |
Ounce of meat per sandwich |
Total ounces |
Pounds to purchase |
Output |
Input |

i.1, p.1 | 16 | “Input number of sandwich” | 50 | ||||

i.2 | 16 | 50 | “Input ounces of meat per sandwich” | 4 | |||

p.2 | 16 | 50 | 4 | 200 | |||

p.3 | 16 | 50 | 4 | 200 | 12.5 | ||

o.1 | 16 | 50 | 4 | 200 | 12.5 | 12.5 |

### 224 Sandwich with 2 Ounce Meat Each

IPO Reference |
Ounces in a pound |
Number of sandwich |
Ounce of meat per sandwich |
Total ounces |
Pounds to purchase |
Output |
Input |

i.1, p.1 | 16 | “Input number of sandwich” | 224 | ||||

i.2 | 16 | 224 | “Input ounces of meat per sandwich” | 2 | |||

p.2 | 16 | 224 | 2 | 448 | |||

p.3 | 16 | 224 | 2 | 448 | 28 | ||

o.1 | 16 | 224 | 2 | 448 | 28 | 28 |

### Question 8

### IPO

Input |
Process |
Output |

i.1 Dental charge | p.1 Copay = 20 p.2 Charge left = Dental charge - copay p.3 Additional pay = Charge left * 0.15 p.4 My cost = Copay + Additional pay p.5 Insurance cost = Dental charge - My cost | o.1 My cost o.2 Insurance cost |

### Flow Chart

### Desk Check

### $110 Dental Charge

IPO Reference |
Co-pay |
Dental charge |
Charge left |
Additional Pay |
My Cost |
Insurance Cost |
Output |
Input |

i.1, p.1 | 20 | “Input dental charge” | 110 | |||||

p.2 | 20 | 110 | 90 | |||||

p.3 | 20 | 110 | 90 | 13.5 | ||||

p.4 | 20 | 110 | 90 | 13.5 | 33.5 | |||

p.5 | 20 | 110 | 90 | 13.5 | 33.5 | 76.5 | ||

o.1 | 20 | 110 | 90 | 13.5 | 33.4 | 76.5 | 33.4 | |

o.2 | 20 | 110 | 90 | 13.5 | 33.4 | 76.5 | 76.5 |

### $200 Dental Charge

IPO Reference |
Co-pay |
Dental charge |
Charge left |
Additional Pay |
My Cost |
Insurance Cost |
Output |
Input |

i.1, p.1 | 20 | “Input dental charge” | 200 | |||||

p.2 | 20 | 200 | 180 | |||||

p.3 | 20 | 200 | 180 | 27 | ||||

p.4 | 20 | 200 | 180 | 27 | 47 | |||

p.5 | 20 | 200 | 180 | 27 | 47 | 153 | ||

o.1 | 20 | 200 | 180 | 27 | 47 | 153 | 47 | |

o.2 | 20 | 200 | 180 | 27 | 47 | 153 | 153 |