Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Ch6AppE03.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//Ch6ConE03.cpp
//Displays a message based on the number
//entered by the user
//Created/revised by <your name> on <current date>

#include <iostream>
using namespace std;

int main()
{

int state = 0;
int charge = 0;
cout << "What state code are you shipping to?";
cin >> state;
switch (state)
{
case 1:
charge = 25;
break;
case 2:
charge = 30;
break;
case 3:
charge = 40;
break;
case 4:
charge = 40;
break;
case 5:
charge = 30;
break;
case 6:
charge = 30;
break;
default:
cout << endl << "Incorrect state code" << endl;
}
cout << charge << endl;
return 0;
}
66 changes: 66 additions & 0 deletions Ch6AppE06.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//Ch6ConE06.cpp
//Displays a message based on the number
//entered by the user
//Created/revised by <your name> on <current date>

#include <iostream>
using namespace std;

int main()
{

char gender = ' ';
char active = ' ';
double cal = 0;
double weight = 0;

cout << endl << "how much do you weigh? ";
cin >> weight;

cout << endl << "A - Moderately active" << endl << "I - inactive" << endl;
cin >> active;

cout << endl << "M - Male" << endl << "F - Female" << endl;
cin >> gender;

gender = toupper(gender);
active = toupper(active);

switch (gender)
{
case 'M':
switch (active)
{
case 'A':
cal = weight * 12;
break;
case 'I':
cal = weight * 10;
break;

default:
cout << endl << "Incorrect input" << endl;
}
break;

case 'F':
switch (active)
{
case 'A':
cal = weight * 15;
break;
case 'I':
cal = weight * 13;
break;

default:
cout << endl << "Incorrect input" << endl;
}
break;

default:
cout << endl << "Incorrect input" << endl;
}
cout << endl << cal << endl;
return 0;
}
77 changes: 77 additions & 0 deletions Ch6AppE08.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
//Ch6AppE08.cpp
//Displays the answer to arithmetic problems
//Created/revised by <your name> on <current date>

#include <iostream>
using namespace std;

int main()
{
double num1 = 0;
double num2 = 0;
double solution = 0;
char choice = ' ';

cout << endl << "A - Addition" << endl << "S - Subtraction" << endl << "M - multiplication" << endl << "D - Division" << endl;
cout << "Which one would you like to do?" << endl;
cin >> choice;
choice = toupper(choice);
switch (choice)
{
case 'A':
cout << "Please enter a number" << endl;
cin >> num1;
cout << "Please enter another number" << endl;
cin >> num2;
solution = num1 + num2;
cout << "Your solution is " << solution << endl;
break;

case 'S':
cout << "Please enter a number" << endl;
cin >> num1;
cout << "Please enter another number" << endl;
cin >> num2;
if (num1 >= num2)
{
solution = num1 - num2;
}
else
{
solution = num2 - num1;
}
cout << "Your solution is " << solution << endl;
break;

case 'M':
cout << "Please enter a number" << endl;
cin >> num1;
cout << "Please enter another number" << endl;
cin >> num2;
solution = num1 * num2;
cout << "Your solution is " << solution << endl;
break;

case 'D':
cout << "Please enter a number" << endl;
cin >> num1;
cout << "Please enter another number" << endl;
cin >> num2;
if (num1 >= num2)
{
solution = num1 / num2;
}
else
{
solution = num2 / num1;
}
cout << "Your solution is " << solution << endl;
break;

default:
cout << endl << "Incorrect input" << endl;
}


return 0;
}