This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class ex4point2 { | |
public static void main(String[] args) { | |
Scanner userInput = new Scanner(System.in); | |
System.out.println("Please enter the latitude and longitude (in degrees) of the first point."); | |
double x1 = userInput.nextDouble(); | |
double y1 = userInput.nextDouble(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a program that prompts the user to enter the distance to drive, the fuel | |
// efficiency of the car in miles per gallon, and the price per gallon, and displays | |
// the cost of the trip. | |
import java.util.Scanner; | |
public class ex2point23 { | |
public static void main(String[] args) { | |
Scanner userInput = new Scanner(System.in); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you know the balance and the annual percentage interest rate, you can compute | |
// the interest on the next monthly payment using the following formula: | |
// interest=balance*(annualInterestRate/1200) | |
// Write a program that reads the balance and the annual percentage interest rate | |
// and displays the interest for the next month. | |
import java.util.Scanner; | |
public class ex2point20 { | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Write a program that reads the subtotal and the gratuity rate, then computes the | |
//gratuity and total. For example, if the user enters 10 for subtotal and 15% for | |
//gratuity rate, the program displays $1.5as gratuity and $11.5 as total. | |
import java.util.Scanner; | |
public class ex2point5 { | |
public static void main(String[] args) { | |
Scanner userInput = new Scanner(System.in); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (Convert pounds into kilograms) Write a program that converts pounds into kilograms. | |
// The program prompts the user to enter a number in pounds, converts it to kilograms, | |
// and displays the result. One pound is 0.454 kilograms. | |
import java.util.Scanner; | |
public class ex2point4 { | |
public static void main(String[] args) { | |
Scanner userInput = new Scanner(System.in); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solve the following: 3.4x + 50.2y = 44.5 | |
// 2.1x + 0.55y = 5.9 | |
public class ex1point13 { | |
public static void main(String[] args) { | |
// Below numbers based on Cramer's formula as solved in notebook | |
double a = 3.4; | |
double b = 50.2; | |
double c = 2.1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ex1point11 { | |
public static void main(String[] args) { | |
int initialPopulation = 312032486; | |
int yearlySeconds = 60 * 60 * 24 * 365; | |
int yearlyBirths = yearlySeconds / 7; | |
int yearlyDeaths = yearlySeconds / 13; | |
int yearlyImmigrants = yearlySeconds / 45; | |
int yearlyPopChange = yearlyBirths + yearlyImmigrants - yearlyDeaths; | |
int popAfterOneYear = initialPopulation + yearlyPopChange; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ex1point10 { | |
public static void main(String[] args) { | |
System.out.println("Assume a runner runs 14 kilometers in 45 minutes and 30 seconds. What is the average speed in miles per hour?"); | |
System.out.println("1 mile = 1.6 kilometers. Therefore, 14 kilometers equals 8.699 miles."); | |
System.out.println("60 minutes are in an hour. Therefore, 45.5 minutes is 0.7583 hours."); | |
System.out.println("We can find the average by dividing 8.699 / 0.7583"); | |
System.out.println(8.699 / 0.7583); | |
System.out.println("The runner progresses approximately 11.5 miles per hour."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a program that displays the area and perimeter of a circle that has a radius | |
//of 5.5 | |
public class ex1point8 { | |
public static void main(String[] args) { | |
double radius; | |
double area; | |
radius = 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ex1point7 { | |
public static void main(String[] args){ | |
System.out.println(4 * (1.0 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11))); | |
System.out.println(4 * (1.0 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1/11) + (1.0/13))); | |
} | |
} |
NewerOlder