CECS 282
LAB ASSIGNMENT #1
Assigned date: 1/24
Due date: 2/1
20 points

Problem 1 [5 points] - Output format 

Write a program named lab11 that calculates and prints monthly paycheck for an employee. The net pay is calculated after taking the following deductions:

Federal Income Tax: 20%
State Tax:   4%
Social Security Tax:  3.5%
Medicare/Medicaid Tax:  2.75%
Pension Plan:  6%
Health Insurance:  $80.0

Your program should prompt the user to input the gross amount. Format your output to have two decimal places. A sample output follows:

Gross amount: 3587.00

Gross amount: $ 3587.00

Federal Tax:   

$ 717.40
State Tax: $ 143.48
Social Security Tax:    $ 125.55
Medicare/Medicaid Tax: $   98.64
Pension Plan:   $ 215.22
Health Insurance: $ 80.00
Net Pay:   $ 2206.71

Note: The bold letters means the computer displays the output. The normal letters means you enter the input.
Net pay = gross amount -(federal tax + state tax + social security tax + Medicare/Medicaid Tax + Pension Plan + Health Insurance)

Hints: You should be able to complete the program with the hints below.

#include <iostream>
#include <iomanip>
using namespace std;
//Declare all constant variables

int main()
{ //Declare variables
your coding
 
// Calculate gross amount, federate tax, sale tax, social security, medicare/medicaid tax, pension plan, health insurance and net pay
your coding
 

//Display output



cout<< left <<  setw(26) << "Gross Amount: "
      << right << " $"
   << setw(7) << grossAmount << endl;

Your coding
 

 return 0;
}

GRADING

Problem 2 [10 points] - Loops

Suppose m and n are integers and m is nonzero. Recall that m is called a divisor of n if n = m for some integer t; that is, when m divides n, the remainder is 0. Moreover, m is called a proper divisor of n if m < n and m divides n. A positive integer is called perfect if it is the sum of its positive proper divisors. For example, the positive proper divisors of 28 are 1, 2, 4, 7, and 14 and 1 + 2 + 4 + 7 + 14 = 28. Therefore, 28 is a perfect.

Link to the perfect numbers 
Write two programs that do the following:

a. Program 1 - name the file as lab21.cpp [6 points]
Output the first four perfect numbers.

b. Program 2 - name the file as lab22.cpp [4 points]
 Input a positive integer number and determine whether the integer is perfect. Validate the input. If the user enters a negative number, ask the user to input another number until a positive number is entered. Terminate the program when the user enters 1.

Hint: When n is divisible by m, the remainder is zero. In C++  there is a operator called %. The % operation finds the remainder of division of one number by another. For instance, the expression "5 %  4" would evaluate to 1 because 5 divided by 4 leaves a remainder of 1, while "9 % 3" would evaluate to 0 because the division of 9 by 3 leaves a remainder of 0. If n % m is zero, then m is a proper divisor of n.

1. Input the number n
    Validate the input - if the input n is less than zero, then ask the user to input the number again until n is not a negative integer number.
2. Create a loop start from i = 1 to n/2
Each iteration
Determine if n mod i is zero. If the result is zero, then accumulate i (sum=sum + i) where sum is initialize to zero before
the loop.
3. After the loop if n is equal to sum, then n is a perfect number.
4. Display the message whether the input number is perfect or not.

Output samples:

Enter a number: 28
28 is a perfect number.

Enter a number: 496
496 is a perfect number.

Enter a number: 6
6 is a perfect number.

Enter a number: 45
45 is not a perfect number.

GRADING

 

 Problem 3 [ 5 points] - Functions

The No Interest Credit Company provides zero-interest loans to customers. (It makes a profit by selling advertising space in its monthly statements and selling its customer lists.) Design an application that gets customer account data that includes an account number, customer name, and balance due. For each customer, display the account number and name; then print the customer's projected balance each month for the next 10 months. Assume that there is no finance charge on this account, that the customer makes no new purchases, and that the customer pays off the balance with equal monthly payments, which are 10 percent of the original bill. This lab assignment is similar to lab assignment 3 except you need to define three functions below.
Name the file as lab5.

  1. void displayColumnTitle();
    Display the column titles
    MONTH     BALANCE DUE

  2. float calculateBlanceDue(float balanceDue, float paymentAmt);
    Calculate and return the balance due.
    balanceDue = balanceDue - paymentAmt;

  3. void dipslayBalance(int month, float balanceDue);
     Display the month and the balance due

Sample output

Enter Account Number (-1 to terminate the input):
123
Enter name: John Nguyen
Enter balance due:
10000.00

Account Number: 123
Name: John Nguyen

MONTH BALANCE DUE
1                           9000.00
2                           8000.00
3                           7000.00
4                           6000.00
5                           5000.00
6                           4000.00
7                           3000.00
8                           2000.00
9                           1000.00
10                               0.00

Enter Account Number (-1 to terminate the input):
456
Enter name: Jose Hernandez
Enter balance due:
25000.00

Account Number: 456
Name: Jose Hernandez

MONTH  BALANCE DUE
1                          22500.00
2                          20000.00
3                          17500.00
4                          15000.00
5                          12500.00
6                          10000.00
7                            7500.00
8                            5000.00
9                            2500.00
10                                0.00

Enter Account Number (-1 to terminate the input):
-1
Thank you.

Program 3 - name the file as lab23.cpp [10 points]

GRADING