Examine the following information and answer questions that follow SengSeng Supe
ID: 3732157 • Letter: E
Question
Examine the following information and answer questions that follow SengSeng SuperMart has 3 stores. The net profit and bonus rate for the manager-in charge of the store is as shown in Table Q1.1 Store ID Address Manager-i Net Profit for 2015 Bonus Rate charge 123 Tuas Street 45 Orchard Road 67 China Street Peter Lim Esther Chia 200,000 300,000 450,000 Tao Table Q1.1 Net Profit Between 200,000 to 300,000 inclusive More than 300.000 Bonus Rate (% Table Q1.2 (a) Determine appropriate data type for the given data in Table Q1.1. Use C++ code to declare these variables (5 marks)Explanation / Answer
Part(a) Solution
int Store_ID;
string Address;
string Manager_in_charge;
double Net_profit;
double Bonus_rate;
Part(b) Solution
#include <iostream>
using namespace std;
int main() {
string manager_name;
double profit;
double bonus_rate;
cout << "Enter Manager Name: ";
cin >> manager_name;
cout << "Enter Net Profit: ";
cin >> profit;
if (profit >= 200000 && profit <= 300000) {
bonus_rate = 0.03;
cout << "Bonus: $" << profit*bonus_rate << " for " << manager_name << endl;
}
else if (profit > 300000) {
bonus_rate = 0.05;
cout << "Bonus: $" << profit*bonus_rate << " for " << manager_name << endl;
}
else {
cout << "Sorry, no bonus for you." << endl;
cout << "Bonus: $0 for " << manager_name << endl;
}
return 0;
}
Part(c) Solution
void calBonus(int store_id, double net_profit, double add_bonus_rate) {
int bonus_rate;
if (net_profit >= 200000.0 && net_profit <= 300000.0)
bonus_rate = 0.03;
else if (net_profit > 300000.0)
bonus_rate = 0.05;
else
bonus_rate = 0.0;
cout << "Bonus: $" << net_profit*bonus_rate << " for Store ID " << store_id << endl;
cout << "Additional Bonus: $" << net_profit*add_bonus_rate << endl;
}
Part(d) Solution
#include <iostream>
using namespace std;
void calBonus(int store_id, double net_profit, double add_bonus_rate) {
int bonus_rate;
if (net_profit >= 200000.0 && net_profit <= 300000.0)
bonus_rate = 0.03;
else if (net_profit > 300000.0)
bonus_rate = 0.05;
else
bonus_rate = 0.0;
cout << "Bonus: $" << net_profit*bonus_rate << " for Store ID " << store_id << endl;
cout << "Additional Bonus: $" << net_profit*add_bonus_rate << endl;
}
int main() {
int store_id;
double profit;
int num_employees;
cout << "Enter Store ID: ";
cin >> store_id;
cout << "Enter Net Profit: ";
cin >> profit;
cout << "Enter Number of Employees: ";
cin >> num_employees;
if (num_employees <= 10)
calBonus(store_id, profit, 0.01);
else
calBonus(store_id, profit, 0.0);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.