package 孙昊楠的项目;
public class ppprogram3 {
public static void main(String[] args) {
System.out.println("Welcome to Java!");
}
}
package 孙昊楠的项目;
public class ppprogram4 {
public static void main(String[] args) {
System.out.print("(10.5 + 2 * 3) / (45 - 3.5) = ");
System.out.println((10.5 + 2 * 3) / (45 - 3.5));
}
}
package 孙昊楠的项目;
public class ppprogram5 {
public static void main(String[] args) {
System.out.println("programming is fun!");
System.out.println("Fundamentals First");
System.out.println("Problem Driven");
}
}
package 孙昊楠的项目;
public class ppprogram6 {
public static void main(String[] args) {
System.out.println(1/0);
}
}
package 孙昊楠的项目;
public class ppprogram7 {
public static void main(String[] args) {
System.out.print("Celsius 35 is Fahrenheit degree ");
System.out.println((9 / 5) * 35 + 32);
}
}
package 孙昊楠的项目;
import java.util.Scanner;
public class ppprogram8 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("enter a number for radius: ");
double radius = input.nextDouble();
double area = radius * radius * 3.14159;
System.out.println("The area for the circle of radius " +
radius +" is " + area);
input.close();
}
}
package 孙昊楠的项目;
import java.util.Scanner;
public class ppprogram9 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("enter three numbers: ");
double number1 = input.nextDouble();
double number2 = input.nextDouble();
double number3 = input.nextDouble();
double average = (number1 + number2 + number3) / 3;
System.out.println("The average of " + number1 + " " + number2
+ " " + number3 + " is "+average);
input.close();
}
}
package 孙昊楠的项目;
public class ppprogram {
public static void main(String[] args) {
double radius;
double area;
radius = 20;
area=radius*radius*3.14159;
System.out.println("The area for the circle of radius "+ radius +"is"+area);
}
}
package 孙昊楠的项目;
import java.util.Scanner;
public class ppprogram10 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter annul interest rate, e.g., 7.25: ");
double annulInterestRate = input.nextDouble();
double monthlyInterestRate = annulInterestRate / 1200;
System.out.print("Enter number of years as an interge, e.d., 5: ");
int numberOfYears = input.nextInt();
System.out.print("Enter loan amount, e.g., 120000.95: ");
double loanAmount = input.nextDouble();
double monthlyPayment = loanAmount * monthlyInterestRate / (1
- 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12));
double totalPayment = monthlyPayment * numberOfYears * 12;
System.out.println("The monthly payment is $" + (int)(monthlyPayment * 100) / 100.0);
System.out.println("The total payment is $" + (int )(totalPayment * 100) / 100.0);
}
}
package 孙昊楠的项目;
import java.util.Scanner;
public class ppprogram11 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter an amount in double, for example 11.56: ");
double amount = input.nextDouble();
int remainingAmount = (int)(amount * 100);
int numberOfOneDollars = remainingAmount / 100;
remainingAmount = remainingAmount % 100;
int numberOfQuarters = (int)remainingAmount / 25;
remainingAmount = remainingAmount % 25;
int numberOfDimes = (int)remainingAmount / 10;
remainingAmount = remainingAmount % 10;
int numberOfNickels = (int)remainingAmount / 5;
remainingAmount = remainingAmount % 5;
int numberOfPennies = remainingAmount;
System.out.println("Your amount " + amount + " consists of");
System.out.println(" " + numberOfOneDollars + " dollars");
System.out.println(" " + numberOfQuarters + " dollars");
System.out.println(" " + numberOfDimes + " dollars");
System.out.println(" " + numberOfNickels + " dollars");
System.out.println(" " + numberOfPennies + " dollars");
}
}