subject 2010 CSE21SDBU-2 × © Che g Study Guided Solut X @ Che ist Senice Group I
ID: 3756728 • Letter: S
Question
subject 2010 CSE21SDBU-2 × © Che g Study Guided Solut X @ Che ist Senice Group ISAK e llireskilled people & eame I wa joh smithtorina max DIS102Nsignmentl pdf × + x C file:/!/C:/Users Adi DownloadsyBIS102 Assignment1.pdf Apps Bookmarks " Facebook Watch Hee Full Mov D Henix Watch tree -Watch I he Flash 20 Fantasy Premier Lea -IMDb Moves IV a YouTube Sustain La Trobe University Other bookmarks Employee Salary Calculator You are to design and code a Java console program for an Employee's salary calculations. The program inputs the employee's details and then calculates and displays a breakdown of their earnings. The program shoukd prompt the user to enter their full name and their gross weekly salary. The program then calculates the employee's nett salary after making the following Income Tax: 20% of Gross salary Medicare Levy: 1.75% of Gross salary Employee Parking space: $8.00 A typical sequence of Input and Output is shown below: NOTE: Text in RED represents the input by the user, bold text represents the output by the and italic text represents the prompts by the program) Please Enter your Name: Bill Kas Please Enter your gross salary: 1275.00 Employee Gross Salary: Income Tax: Medicare Levy: Employee Parking: Bill Kas $1275.00 $255.00 $22.31 $8.00 NETT SALARY $989.69 NOTE: The output from your program does NOT have to have the above formatting,) In Exercise 02 you are to use the code in Exercise 1 but now the Income Tax payable is not a flat rate but depends on the gross salary as shown in the table below: Gross Salary 0 to less than $500 Tax Rate 15.0% 7:33 PM 9/29/2018Explanation / Answer
//Exercise 01
import java.util.Scanner;
class Employee
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
String name;
double grossSalary;
double incTax,medLevy,empPark = 8.00;
double netSalary;
System.out.print("Please Enter Your Name: ");
name = in.nextLine();
System.out.print("Please Enter your gross salary: ");
grossSalary = in.nextDouble();
incTax = Math.grossSalary*0.2;
medLevy = grossSalary*1.75/100;
netSalary = grossSalary-(incTax+medLevy+empPark);
System.out.println("Employee: "+name);
System.out.printf("Gross Salary: %.2f ",grossSalary);
System.out.printf("Income Tax: %.2f ",incTax);
System.out.printf("Medicare Levy: %.2f ",medLevy);
System.out.printf("Employee Parking: %.2f ",empPark);
System.out.println(" Net Salary: "+netSalary);
}
}
//Exercise 02
import java.util.Scanner;
class Employee
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
String name;
double grossSalary;
double incTax = 0.0;
double medLevy,empPark = 8.00;
double netSalary;
System.out.print("Please Enter Your Name: ");
name = in.nextLine();
System.out.print("Please Enter your gross salary: ");
grossSalary = in.nextDouble();
if(grossSalary>=(double)0 && grossSalary<(double)500)
{
incTax = grossSalary*0.15;
}
else if(grossSalary>=(double)500 && grossSalary<(double)1000)
{
incTax = grossSalary * 0.18;
}
else if(grossSalary>=(double)1000)
{
incTax = grossSalary * 0.20;
}
medLevy = grossSalary*1.75/100;
netSalary = grossSalary-(incTax+medLevy+empPark);
System.out.println("Employee: "+name);
System.out.printf("Gross Salary: %.2f ",grossSalary);
System.out.printf("Income Tax: %.2f ",incTax);
System.out.printf("Medicare Levy: %.2f ",medLevy);
System.out.printf("Employee Parking: %.2f ",empPark);
System.out.println(" Net Salary: "+netSalary);
}
}
//Travel.java
import java.util.Scanner;
class Travel
{
double bookingCost = 50.00;// i have taken booking Cost as 50.00 because you have never mentioned it,u can change that
public double CalcBaseCost(int age,int overseas)
{
if(overseas==1)
{
return (double)35.50;
}
else
{
return (double)26.50;
}
}
public double CalcOptionsCost(int option,int overseas)
{
double cost = 0.0;
if(option==1)
{
if(overseas==1)
{
cost =(double)12.50;
}
else
{
cost = (double)9.50;
}
}
else if(option==2)
{
cost = CalcOptionsCost(1,overseas)+(double)250;
}
else if(option==3)
{
cost = CalcOptionsCost(2,overseas)+bookingCost;
}
return cost;
}
public double CalcPreExistingCost(int age,int preCond)
{
if(preCond==1)
{
if(age<60)
{
return (double)0.10;
}
else
{
return (double)0.12;
}
}
else
{
return (double)0;
}
}
public static void main(String args[])
{
Travel ob = new Travel();
String name,address;
int overseas,preCond;
int age,option,numOfDays;
Scanner in = new Scanner(System.in);
System.out.print("Enter Name: ");
name = in.nextLine();
System.out.print("Enter Address(it should be in ne line): ");
address = in.nextLine();
System.out.print("Enter Age: ");
age = in.nextInt();
System.out.print("Enter NUmber of days Spent: ");
numOfDays = in.nextInt();
System.out.print("Enter 1.overseas 0.country");
overseas = in.nextInt();
if(overseas!=1 && overseas!=0)
{
System.out.println("Invalid Overseas input");
System.exit(0);
}
System.out.print("Enter 1.pre-existing medical conditions 0.No pre-conditions");
preCond =in.nextInt();
if(preCond!=1 && preCond!=0)
{
System.out.println("Invalid preCond input");
System.exit(0);
}
System.out.println("Choose One of the Insurance Cover options: ");
System.out.println("1.Option 1 =>Medical Cover Only");
System.out.println("2.Option 2 =>Option 1 + Loss of valuables up to $5000");
System.out.println("3.Option 3 =>Option 2 + Loss of Booking");
System.out.print("Enter Your choice: ");
option = in.nextInt();
if(option!=1 && option!=2 && option!=3)
{
System.out.println("Invalid option input");
System.exit(0);
}
double baseCost = ob.CalcBaseCost(age,overseas);
double optionsCost = ob.CalcOptionsCost(option,overseas);
double preExistCost = ob.CalcPreExistingCost(age,preCond);//CalcPreExistingCost(age,preCond) returns percentage of extra money to add to base cost
if(preExistCost!=(double)0)
{
preExistCost = baseCost + baseCost*preExistCost;
}
double totalCost = (baseCost+optionsCost+preExistCost) * numOfDays;
System.out.println("Base Cost: "+baseCost);
System.out.println("Options Cost: "+optionsCost);
System.out.println("PreExisting Conditions Cost: "+preExistCost);
System.out.println("Total Cost: "+totalCost);
}
}
//Exercise 04
import java.util.Scanner;
class ArrayOp
{
double[] array = new double[10];
public void DisplayReverse()
{
int i;
for(i=9;i>=0;i--)
{
System.out.print(array[i]+" ");
}
System.out.println();
}
public void DisplaySum()
{
int i;
double sum = 0.0;
for(i=9;i>=0;i--)
{
sum+=array[i];
}
System.out.println("Sum = "+sum);
}
public void DisplayAverage()
{
int i;
double sum = 0.0;
for(i=9;i>=0;i--)
{
sum+=array[i];
}
System.out.println("Average = "+sum/10);
}
public void DisplayLessThan(double num)
{
int i;
for(i=0;i<10;i++)
{
if(array[i]<num)
{
System.out.println(array[i]+" < "+num);
}
}
}
public static void main(String args[])
{
ArrayOp ob = new ArrayOp();
Scanner in = new Scanner(System.in);
int i;
for(i=0;i<10;i++)
{
System.out.print("Enter Array["+(i+1)+"] = ");
ob.array[i] = in.nextDouble();
}
ob.DisplayReverse();
ob.DisplaySum();
ob.DisplayAverage();
double num;
System.out.print("Enter num to check < the array elms:");
num =in.nextDouble();
ob.DisplayLessThan(num);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.