java 格式化 整数 部位_java-如何格式化打印整数,使小数点行左侧的所有位置都对齐?_java_酷徒编程知识库...

import java.util.Scanner;

import java.time.LocalDate;

import java.time.Period;

/**

*Program generates pay stub for employee.

*Details several variables.

* @author Taylor Schaefer ts1178

* @version 19

*/

public class PayStub {

/**

* @param args insert description here

*/

public static void main(String[] args) {

//Install scanner and declare all variable

Scanner keyboard = new Scanner(System.in);

//Inputting name

System.out.print("Enter your Fullname:");

String fullName = keyboard.nextLine();

//Inputting anniversary month

System.out.print("Enter your Anniversary Month(1-12):");

int month = keyboard.nextInt();

//Inputting anniversary year

System.out.print("Enter your Anniversary Year:");

int year = keyboard.nextInt();

//Hours per week worked

System.out.print("Enter your hours worked this pay period(0-350):");

int hours = keyboard.nextInt();

//Inputting name

System.out.print("Enter your Job Title:");

String blank = keyboard.nextLine();

String jobTitle = keyboard.nextLine();

//Hourly pay rate

System.out.print("Enter your pay rate:");

double rate = keyboard.nextDouble();

//current pay month 9

//current pay year 2018

int day = 1;

LocalDate start = LocalDate.of(year, month, day);

LocalDate today = LocalDate.of(2018, 9, 1);

//calculate the time that has passed

Period age = Period.between(start, today);

int years = age.getYears();

int months = age.getMonths();

//Print total number of months worked and declare variable total months

int totalMonths = months + years * 12;

//Declare Variable vacation Hours

double vacation = totalMonths * 8.25;

//Declare and define gross pay

double grossPay = hours * rate;

//Declare and calculate retirement

double retirement = grossPay * .052;

//Declare and calculate tax withholding

double tax = (grossPay - retirement) * .28;

//Declare and calculate net pay

double netPay = grossPay - (tax + retirement);

//Print Payroll

//

System.out.println();

System.out.println();

System.out.println("==========================================");

//Company Name

System.out.println(" Gekko & Co.");

System.out.println();

//Print Logo

System.out.println(""$"");

System.out.println(" ~~~");

System.out.println(" / `.");

System.out.println(" / /");

System.out.println(" /_ _ _ /");

System.out.println(); //divider

//Single Line Divider

System.out.println("------------------------------------------");

//Print Pay Period

System.out.println("Pay Period: 9/2018");

//Print Name

System.out.println("Name:" + fullName);

//Print Title

System.out.println("Title:" + jobTitle);

//Print anniversary month and year

System.out.println("Anniversary:" + month +"/" + year);

//Print months worked

System.out.println("Months Worked:" + totalMonths +" months");

//Print vacation hours earned

System.out.printf("Vacation hours: %.2fn", vacation);

//Single Line Divider

System.out.println("------------------------------------------");

//Print Gross Pay

System.out.printf("Gross Pay: $%.2fn", grossPay);

//Print Retirement Amount

System.out.printf("Retirement: $ %.2fn", retirement);

//Print Tax withholding amount

System.out.printf("Tax: $%.2fn", tax);

//Single Line Divider

System.out.println("------------------------");

//Print Net Pay

System.out.printf("Net Pay: $%.2fn", netPay);

//Print Footer

System.out.println("==========================================");

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值