0% found this document useful (0 votes)
23 views3 pages

Salary Increase and Pay Calculation Program

Uploaded by

Hazel Jeon
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Salary Increase and Pay Calculation Program

Uploaded by

Hazel Jeon
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. Workers at a particular company have won a 7.6% pay increase in monthly salary.

Moreover the increase is


retroactive for six months. Write a program that takes an employee’s previous annual salary as input and
then outputs the amount of retroactive pay due the employee, the new annual salary and the new monthly
salary.

Pseudocode:

Input : employee’s previous annual salary (epap)


Outputs : Amount of retroactive pay due the employee (arp)
New annual salary (nas)
New monthly salary (nms)

a. Ask user to enter employee’s previous annual salary (epap)


b. Using employee’s previous annual salary, Amount of retroactive pay due the employee (arp) can be computed;
arp = (epap * 0.076) / 2.0
c. With the computed amount of retroactive pay due the employee (arp), new annual salary (nas) is;
nas = epap + (arp*2)
d. New monthly salary (nms) can be computed using computed new annual salary (nas)
nms = nas / 12
e. Display the computed value of:
● Amount of retroactive pay due the employee (arp)
● New annual salary (nas)
● New monthly salary (nms)

Program code:

#include <iostream.h>

int main()
{
double epap, arp, nas, nms;

cout<<”please enter employee’s previous annual salary: “;


cin>>epap;

arp = (epap * 0.076) / 2.0;


nas = epap + (arp*2);
nms = nas / 12;

cout<<” Amount of retroactive pay due the employee “<<arp<<endl


<<” New monthly salary “<<nas<<endl
<<” New monthly salary “<<nms;

return 0;
}

2. A class has four exams in one term. Write a program that reads in a student’s four exam scores as integers
and then outputs the student’s average.

Pseudocode:
Inputs : four exam scores as integers (q1, q2, q3, and q4)
Outputs : average of four exams (ave_ex)

a. Get scores of four exams


b. Compute for the average
c. Display the average score

Program code:

#include <iostream.h>
#include <conio.h>

int main()
{
int q1, q2, q3, q4;
double ave_ex;
clrscr();
cout<<”enter the score of exams…”<<endl
<<”exam #1: “;
cin>>q1;
cout<<”exam #2: ”;
cin>>q2;
cout<<”exam #3: ”;
cin>>q3;
cout<<”exam #4: ”;
cin>>q4;

ave_ex = ( q1+q2+3+q4 ) / 4.0;

cout<<”average of four exams is “<<ave_ex<<endl


<<”\n\n\n\n\npress any key to terminate.”;
getch();
return 0;
}

3. Write a program to read in the weight in pounds and ounces and output the weight expressed in kilograms
and grams. One pound equals 0.453592 kilograms. Use a constant declaration.

Pseudo code:
Inputs - 2; weight in pounds and ounces
Outputs - 2; weight expressed in kilograms and grams

1 pound = 0.453592 kilograms

a. Ask user to enter weight in pounds and ounces (w_lbs and w_oz)
b. Compute total weight in pounds
c. Compute for the equivalent weight in kilograms and grams (w_kg and w_g)
d. Display equivalent weight

Program code:

#include <iostream.h>
#include <conio.h>

int main()
{
double w_lbs, w_oz;
int w_kg, w_g;

clrscr();
cout<<”kindly enter weight in: \n”
<<”pounds: “;
cin>>w_lbs;
cout<<”ounces: “;
cin>>w_oz;

w_lbs += w_oz * 0.0625;


w_kg = int (w_lbs * 0.453592);
w_g = ((w_lbs * 0.453592) – w_kg) * 1000;

cout<<”equivalent weight in:\n”


<<”kilogram : “<<w_kg
<<”grams : “<<w_g;
getch();
return 0;
}
4. Write a program that calculates the change for a cashier. The program requests the cost of the item. The user
then types in the cost as a decimal numeral. The program then outputs the cost of the item including the
sales tax. (Use 6% as the sales tax value). The program next requests and receives the amount tendered by
the customer. Finally the program outputs the summary of all figures, including the amount of change due to
the customer. Use a constant declaration for the tax rate.

Pseudo code:
Inputs - cost of item (coi)
Amount tendered by customer
Outputs - cost of item including tax (coit)
Summary of all figures
Sales tax value = 6%

a. Let user enter the cost of an item (coi)


b. Compute for the cost of item including tax (coit)
coit = coi * 1.06
c. Display cost of item with tax
d. Let user enter amount tendered by customer (atc)
e. Compute for change due to customer (cdc)
cdc = atc – coit
f. Display summary
- Cost of item
- Cost of item with tax
- Amount tendered by customer
- Change due to customer

Program code:

#include <iostream.h>
#include <conio.h>

int main()
{
double coi, coit, atc, cdc;

clrscr();
cout<<”please enter cost of item: “;
cin>>coi;

coit = coi * 1.06;

cout<<”cost of item with tax : “<<coit<<endl


<<”\nplease enter amount tendered by customer: “;
cin>>atc;

cdc = atc – coit;

cout<<”summary…\n”
<<”cost of item : “<<coi<<endl
<<”cost of item including tax : “<<coit<<endl
<<”amount tendered : “<<atc<<endl
<<”change due to customer : “<<cdc;

getch();
return 0;
}

Common questions

Powered by AI

The conversion factor of 0.453592 kilograms per pound ensures high accuracy because it reflects a standard SI (International System of Units) conversion value, minimizing discrepancies in weight translation. For calculating grams from pounds and ounces, the program begins by converting ounces to a fractional pound value and adds it to the total pounds. It then multiplies the resulting weight by the conversion factor to get kilograms. The integer part of the kilogram calculation represents full kilograms, and the fractional part is multiplied by 1000 to derive grams, allowing for a fine-grained conversion from imperial to metric units .

The program computes the average of four exam scores by first collecting each score from the user as input. It then calculates the average by summing all the scores and dividing the total by four (ave_ex = (q1 + q2 + q3 + q4) / 4.0). Finally, it outputs the computed average score .

Incorrect arithmetic operations in the exam scoring program can result in erroneous computations of the average score. For instance, an error such as improper summation of scores or dividing by the wrong number could lead to inaccurate representations of student performance. This miscalculation could misinform educational assessments and decisions based on the output, such as grading or identifying areas for improvement. It highlights the need for precision in coding operations to ensure reliable and actionable outcomes .

Accurate float-to-integer conversions are critical in the weight conversion program to prevent the loss of precision and ensure that integer values accurately represent the computed weights. In the conversion process, the program calculates weight in kilograms as a floating-point to capture the whole and fractional parts of the calculation. The whole number is extracted as an integer to represent complete kilograms, while the decimal fraction is converted to grams by scaling and rounding as necessary. This careful handling of conversions ensures that the output precisely reflects the physical weight, eliminating rounding errors that might misrepresent the true weight when transitioning from continuous to discrete units .

The computational logic involves calculating half of the annual raise amount to determine the retroactive pay. The logic is based on applying a 7.6% annual pay increase over the previous salary, calculated for only six months as the pay raise is retroactive. This results in arp = (epap * 0.076) / 2.0 for the six months. Multiplying this by two ensures the new annual salary reflects a full year's pay adjusted by the raise. This methodical computation guarantees that the employee is compensated correctly for the period prior to the increase being applied, maintaining fairness and precision in salary adjustment .

The constant declaration in both programs serves to maintain a fixed value for conversion and calculation purposes, ensuring accuracy and consistency. In the weight conversion program, it uses a constant to define the conversion factor from pounds to kilograms, preventing any accidental changes to the conversion rate. Similarly, in the sales tax calculation program, a constant declaration for the tax rate ensures that the tax is consistently applied at a rate of 6%, avoiding any errors in manual entry or recalculation .

The program handles user inputs by initially prompting the user to input the cost of an item. It then computes and displays the cost with tax included. Subsequently, it asks the user to enter the amount tendered by the customer. Utilizing these inputs, it calculates the change due by subtracting the tax-inclusive cost from the amount tendered. These user inputs are crucial because they tailor the calculation to real-world transactions, allowing the program to dynamically compute relevant financial figures and offer an accurate summary of the transaction sans any prior assumptions about the values .

The program calculates the cost of an item including sales tax by multiplying the original cost by 1.06, using 6% as the sales tax rate (coit = coi * 1.06). After displaying this tax-included cost, the program prompts the user to enter the amount tendered by the customer. It then computes the change to be returned by subtracting the tax-included cost from the tendered amount (cdc = atc - coit). The program concludes by outputting a summary of the original cost, tax-included cost, amount tendered by the customer, and the change due .

The conversion from pounds and ounces to kilograms and grams uses the constant conversion factor where one pound equals 0.453592 kilograms. The program first asks the user to enter the weight in pounds and ounces. It then adds the equivalent pounds of the entered ounces using the factor 0.0625 (since there are 16 ounces in a pound). Then, the total weight in pounds is used to calculate the weight in kilograms by multiplying by 0.453592. The kilogram portion is extracted as an integer, and the remaining decimal part is converted to grams by multiplying by 1000 .

The program calculates the retroactive pay for an employee by acknowledging a 7.6% salary increase, retroactive for six months. The specific steps include: a) computation of the retroactive pay based on half a year's increase (arp = (epap * 0.076) / 2.0), b) determination of the new annual salary by adding double the retroactive pay to the previous salary (nas = epap + (arp * 2)), and c) calculation of the new monthly salary by dividing the new annual salary by 12 (nms = nas / 12). It outputs these computed values for retroactive pay due, new annual salary, and new monthly salary .

You might also like