0% found this document useful (0 votes)
44 views4 pages

CSCI250L Exercises 2.23 2.25 Solutions

Uploaded by

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

CSCI250L Exercises 2.23 2.25 Solutions

Uploaded by

Abbas Osman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CSCI250L Exercises and

Solutions

Exercises: 2.23, 2.25 Page 74

Prepared By: Rizkallah Bachour


import java.util.Scanner;
public class Exercise_02_23 {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.print("Enter an ASCII code: ");
int x = input.nextInt();
System.out.println("The character is " + (char)x);

}
}
import java.util.Scanner;
public class Exercise02_25 {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.print("Enter Employee's name:");
String name = input.next();
System.out.print("Enter number of hours worked:");
double hoursWorked = input.nextDouble();
System.out.print("Enter hourly pay rate:");
double hourlyRate = input.nextDouble();
System.out.print("Enter federal tax withholding rate:");
double fedTaxWithholdingRate = input.nextDouble();
System.out.print("Enter state tax withholding rate:");
double stateTaxWithholdingRate = input.nextDouble();

//note the usefulness of setting variables here


double grossPay = hourlyRate * hoursWorked;
double fedWithholding = (grossPay *
fedTaxWithholdingRate)/100;
double stateWithholding = (grossPay *
stateTaxWithholdingRate)/100;
double totalDeduction = fedWithholding + stateWithholding;
double netPay = grossPay - totalDeduction;

System.out.println("Employee name: " + name);


System.out.println("Hours Worked: " + hoursWorked);
System.out.println("Pay Rate: " + hourlyRate);
System.out.println("Gross pay: " + grossPay);
System.out.println("Deductions: ");
System.out.println("\tFederal Withholding " + "(" +
fedTaxWithholdingRate +"%): $" + fedWithholding);
System.out.println("\tState Withholding " + "(" +
stateTaxWithholdingRate +"%): $" + stateWithholding);
System.out.println("\tTotal Deduction: $" +
totalDeduction);
System.out.println("Net Pay: $" + netPay);

}
}

You might also like