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";
  }
 }
}

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