本文共 5524 字,大约阅读时间需要 18 分钟。
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a degree in Celsius:"); double c = input.nextDouble(); double h = (9.0/5)*c+32; System.out.println(c+" Celsius is "+h+" Fahrenheit."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { double pi = 3.141592654; System.out.print("Enter the radius and length of a cylinder:"); Scanner input = new Scanner(System.in); double r = input.nextDouble(); double l = input.nextDouble(); double s = r*r*pi; double v = s*l; System.out.println("The area is "+s); System.out.println("The volume is "+v); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a value for feet:"); double feet = input.nextDouble(); double meters = feet*0.305; System.out.println(feet+" feet is "+meters+" meters."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a value in pounds:"); double pounds = input.nextDouble(); double kilograms = pounds*0.454; System.out.println(pounds+" pounds is "+kilograms+" kilograms."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the subtotal and a gratuity rate:"); double t = input.nextDouble(); double g = input.nextDouble(); double extra = t*g/100.0; double s = extra+t; System.out.println("The gratuity is $"+extra+" and total is $"+s+"."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number between 0 and 1000:"); int num = input.nextInt(); int d1 = num%10; num/=10; int d2 = num%10; num/=10; int s = num+d1+d2; System.out.println("The sum of the digits is "+s+"."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of minutes:"); int min = input.nextInt(); int days = min/60/24; int years = days/365; days %= 365; System.out.println(min+" minutes is approximately "+years+" years and "+days+" days."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the time zone offset to GMT:"); long offset = input.nextLong(); long totalMilliseconds = System.currentTimeMillis(); totalMilliseconds+=offset*60*60*1000; long totalSeconds = totalMilliseconds/1000; long currentSecond = totalSeconds%60; long totalMinutes = totalSeconds/60; long currentMinute = totalMinutes%60; long totalHours = totalMinutes/60; long currentHour = totalHours%24; System.out.println("Current time is "+currentHour+":"+currentMinute+":"+currentSecond+" GMT."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter v0, v1, and t:"); double v0 = input.nextDouble(); double v1 = input.nextDouble(); double t = input.nextDouble(); double a = (v1-v0)/t; System.out.println("The average acceleration is "+a+"."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the amount of water in kilograms:"); double m = input.nextDouble(); System.out.print("Enter the initial temperature:"); double it = input.nextDouble(); System.out.print("Enter the final temperature:"); double ft = input.nextDouble(); double q = m*(ft-it)*4184; System.out.println("The energy needed is "+q+"."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the number of years:"); int year = input.nextInt(); double base = 312032486; int secnum = 365*24*3600; for(int i=1;i<=year;i++) base=base+secnum/7.0-secnum/13.0+secnum/45.0; System.out.println("The population in "+year+" years is "+base+"."); }}
import java.util.Scanner;public class book { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter speed and acceleration:"); double v = input.nextDouble(); double a = input.nextDouble(); double l = v*v/(2*a); System.out.println("The minimum runway length for this airplane is "+l+"."); }}
转载地址:http://mkwai.baihongyu.com/