Tuesday, December 11, 2018
Tuesday, October 09, 2018
Monday, July 30, 2018
Thursday, July 12, 2018
Wednesday, June 27, 2018
Monday, June 11, 2018
Thursday, April 19, 2018
Monday, March 19, 2018
Thursday, March 15, 2018
Chapter 7 Homework Conditions and Test Results
Test 1
Enter a string: Larry Hobbs
Before removing vowels: Larry
After removing vowels: Lrry
Test 2
Enter a string: LarryHobbs
Before removing vowels: LarryHobbs
After removing vowels: LrryHbbs
Test 3
Enter a string: ThankGodItIsFriday
Before removing vowels: ThankGodItIsFriday
After removing vowels: ThnkGdtsFrdy
Test 4
Enter a string: ILoveC++
Before removing vowels: ILoveC++
After removing vowels: LvC++
Test 5
Enter a string: abcdefghijklmnopqrstuvwxyz
Before removing vowels: abcdefghijklmnopqrstuvwxyz
After removing vowels: bcdfghjklmnpqrstvwxyz
Test 6
Enter a string: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Before removing vowels: ABCDEFGHIJKLMNOPQRSTUVWXYZ
After removing vowels: BCDFGHJKLMNPQRSTVWXYZ
Sample of multi-dimensional array done in class
#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
const int NO_ROOMS = 4;
const int NO_LEVELS = 3;
const int NO_ROWS = 9;
const int NO_SEATS = 15;
const string filler = " _____________________________________________________________";
enum room { ROOM1, ROOM2, ROOM3, ROOM4 };
enum level { FRONT, MIDDLE, UPPER };
enum rows { A, B, C, D, E, F, G, H, I, J };
int main()
{
char theater[NO_ROOMS][NO_LEVELS][NO_ROWS][NO_SEATS];
int i, j, k, l;
char seat;
for (i = 0; i < NO_ROOMS; i++)
for (j = 0; j < NO_LEVELS; j++)
for (k = 0; k < NO_ROWS; k++)
for (l = 0; l < NO_SEATS; l++)
theater[i][j][k][l] = ' ';
theater[2][2][5][8] = 'X';
theater[1][3][10][15] = 'X';
theater[2][1][9][2] = 'X';
for (i = 0; i < NO_ROOMS; i++)
{
cout << "Room " << i + 1 << endl;
for (j = 0; j < NO_LEVELS; j++)
{
cout << " Level " << j + 1 << endl;
cout << filler << endl;
for (k = 0; k < NO_ROWS; k++)
{
cout << "Row " << k + 1 << "|";
for (l = 0; l < NO_SEATS; l++)
{
if (theater[i][j][k][l] == 'X')
cout << " " << theater[i][j][k][l] << " |";
else
cout << " " << l << " |";
}
cout << endl << filler << endl;
}
cout << "\n\n";
}
}
}
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
const int NO_ROOMS = 4;
const int NO_LEVELS = 3;
const int NO_ROWS = 9;
const int NO_SEATS = 15;
const string filler = " _____________________________________________________________";
enum room { ROOM1, ROOM2, ROOM3, ROOM4 };
enum level { FRONT, MIDDLE, UPPER };
enum rows { A, B, C, D, E, F, G, H, I, J };
int main()
{
char theater[NO_ROOMS][NO_LEVELS][NO_ROWS][NO_SEATS];
int i, j, k, l;
char seat;
for (i = 0; i < NO_ROOMS; i++)
for (j = 0; j < NO_LEVELS; j++)
for (k = 0; k < NO_ROWS; k++)
for (l = 0; l < NO_SEATS; l++)
theater[i][j][k][l] = ' ';
theater[2][2][5][8] = 'X';
theater[1][3][10][15] = 'X';
theater[2][1][9][2] = 'X';
for (i = 0; i < NO_ROOMS; i++)
{
cout << "Room " << i + 1 << endl;
for (j = 0; j < NO_LEVELS; j++)
{
cout << " Level " << j + 1 << endl;
cout << filler << endl;
for (k = 0; k < NO_ROWS; k++)
{
cout << "Row " << k + 1 << "|";
for (l = 0; l < NO_SEATS; l++)
{
if (theater[i][j][k][l] == 'X')
cout << " " << theater[i][j][k][l] << " |";
else
cout << " " << l << " |";
}
cout << endl << filler << endl;
}
cout << "\n\n";
}
}
}
Thursday, March 08, 2018
Chapter 6 Homework Conditions and Test Results
Test 1 Enter yearly income: 15000 Enter the hourly rate: 70 Enter consulting time in minutes: 75 The billing amount is: 21.00 Test 2 Enter yearly income: 50000 Enter the hourly rate: 70 Enter consulting time in minutes: 20 The billing amount is: 0.00 Test 3 Enter yearly income: 50000 Enter the hourly rate: 70 Enter consulting time in minutes: 21 The billing amount is: 0.82 Test 4 Enter yearly income: 150000 Enter the hourly rate: 50 Enter consulting time in minutes: 180 The billing amount is: 93.33 Test 5 Enter yearly income: 35000 Enter the hourly rate: 25 Enter consulting time in minutes: 90 The billing amount is: 20.42
Wednesday, February 28, 2018
Chapter 5 Homework Conditions and Test Results
1. Ask for 2 numbers
2. Calculate how many multiples there are between the 2 numbers entered
A. How many multiples of 3 are there
B. How many multiples of 5 are there
3. Output the results
==========================================
Solution
Test 1
Enter two integers: 1 3
Multiples of 3 between 1 and 3: 1
Multiples of 5 between 1 and 3: 0
Test 2
Enter two integers: 100 5000
Multiples of 3 between 100 and 5000: 1633
Multiples of 5 between 100 and 5000: 981
Test 3
Enter two integers: 50 2
Multiples of 3 between 2 and 50: 16
Multiples of 5 between 2 and 50: 10
Test 4
Enter two integers: 451 21345
Multiples of 3 between 451 and 21345: 6965
Multiples of 5 between 451 and 21345: 4179
Test 5
Enter two integers: 3 3
Multiples of 3 between 3 and 3: 1
Multiples of 5 between 3 and 3: 0
Test 6
Enter two integers: 5 5
Multiples of 3 between 5 and 5: 0
Multiples of 5 between 5 and 5: 1
2. Calculate how many multiples there are between the 2 numbers entered
A. How many multiples of 3 are there
B. How many multiples of 5 are there
3. Output the results
==========================================
Solution
Test 1
Enter two integers: 1 3
Multiples of 3 between 1 and 3: 1
Multiples of 5 between 1 and 3: 0
Test 2
Enter two integers: 100 5000
Multiples of 3 between 100 and 5000: 1633
Multiples of 5 between 100 and 5000: 981
Test 3
Enter two integers: 50 2
Multiples of 3 between 2 and 50: 16
Multiples of 5 between 2 and 50: 10
Test 4
Enter two integers: 451 21345
Multiples of 3 between 451 and 21345: 6965
Multiples of 5 between 451 and 21345: 4179
Test 5
Enter two integers: 3 3
Multiples of 3 between 3 and 3: 1
Multiples of 5 between 3 and 3: 0
Test 6
Enter two integers: 5 5
Multiples of 3 between 5 and 5: 0
Multiples of 5 between 5 and 5: 1
Chapter 4 Homework Conditions and Test Results
1. Ask for the Bill Amount
2. Ask for the Amount being paid
3. Calculate what the amount being paid compares to the balance for credits and penalties
A. If you pay in full, you get either $10 or 1% credit(whichever is smaller)
B. If you pay at least 50% of the Bill, a 5% penalty is applied to the remaining balance.
C. If you pay at least 20% and less than 50% of the Bill, a 10% penalty is applied to the remaining balance.
D. If you pay any other balance amount of the Bill, a 20% penalty is applied to the remaining balance.
4. Calculate the output results and present to the user
A. Penalties or Credit if applicable
B. Remaining Balance
===============================================
Solution
Test 1
Enter the billing amount: 500
Enter the payment amount: 500
Thank you for paying the full amount.
You will receive $5.00 credit on your next bill.
Test 2
Enter the billing amount: 500
Enter the payment amount: 600
The penalty added to the next bill is: $-5.00
The unpaid balance including the penalty is: $-105.00
Test 3
Enter the billing amount: 50
Enter the payment amount: 10
The penalty added to the next bill is: $4.00
The unpaid balance including the penalty is: $44.00
Test 4
Enter the billing amount: 5000
Enter the payment amount: 25
The penalty added to the next bill is: $995.00
The unpaid balance including the penalty is: $5970.00
Test 5
Enter the billing amount: 500
Enter the payment amount: 251
The penalty added to the next bill is: $12.45
The unpaid balance including the penalty is: $261.45
2. Ask for the Amount being paid
3. Calculate what the amount being paid compares to the balance for credits and penalties
A. If you pay in full, you get either $10 or 1% credit(whichever is smaller)
B. If you pay at least 50% of the Bill, a 5% penalty is applied to the remaining balance.
C. If you pay at least 20% and less than 50% of the Bill, a 10% penalty is applied to the remaining balance.
D. If you pay any other balance amount of the Bill, a 20% penalty is applied to the remaining balance.
4. Calculate the output results and present to the user
A. Penalties or Credit if applicable
B. Remaining Balance
===============================================
Solution
Test 1
Enter the billing amount: 500
Enter the payment amount: 500
Thank you for paying the full amount.
You will receive $5.00 credit on your next bill.
Test 2
Enter the billing amount: 500
Enter the payment amount: 600
The penalty added to the next bill is: $-5.00
The unpaid balance including the penalty is: $-105.00
Test 3
Enter the billing amount: 50
Enter the payment amount: 10
The penalty added to the next bill is: $4.00
The unpaid balance including the penalty is: $44.00
Test 4
Enter the billing amount: 5000
Enter the payment amount: 25
The penalty added to the next bill is: $995.00
The unpaid balance including the penalty is: $5970.00
Test 5
Enter the billing amount: 500
Enter the payment amount: 251
The penalty added to the next bill is: $12.45
The unpaid balance including the penalty is: $261.45
Tuesday, February 27, 2018
Subscribe to:
Posts (Atom)