Variables Review Doc

This commit is contained in:
2026-10-29 13:33:45 -04:00
parent 7758699dde
commit 10e1ead94c
9 changed files with 110 additions and 93 deletions
+23
View File
@@ -0,0 +1,23 @@
import java.util.Scanner;
public class CylinderCalculator {
public CylinderCalculator() {}
public void display() {
Scanner scanner = new Scanner(System.in);
System.out.print("Height of the cylinder:");
int height = scanner.nextInt();
System.out.print("Radius of the cylinder:");
int radius = scanner.nextInt();
System.out.printf("The surface area of the cylinder is: %.1f and the volume is %.1f",
Math.TAU*radius*height + Math.TAU*radius*2,
Math.PI * radius * 2 * height
);
}
public static void main(String[] args) {
CylinderCalculator r = new CylinderCalculator();
r.display();
}
}
-33
View File
@@ -1,33 +0,0 @@
public class EmployeeEarnings {
EmployeeEarnings() {
}
public void top() {
System.out.printf("%50s %n%n","MWPSB Employee Earnings");
System.out.printf("%-20s %-20s %-20s %-20s %n %n","Employee","Hourly Rate","Hours per week","Gross Monthly Salary");
}
public void data() {
String name1 = "Akane Tsunemori";
String name2 = "Shinya Kogami";
String name3 = "Shusei Kagari";
double rate1 = 31.5;
double rate2 = 18.25;
double rate3 = 22;
int hours1 = 45;
int hours2 = 24;
int hours3 = 37;
System.out.printf("%-20s $%-20.2f%-20d $%-20.2f %n", name1, rate1, hours1, rate1*hours1*4);
System.out.printf("%-20s $%-20.2f%-20d $%-20.2f %n", name2, rate2, hours2, rate2*hours2*4);
System.out.printf("%-20s $%-20.2f%-20d $%-20.2f %n", name3, rate3, hours3, rate3*hours3*4);
}
public static void main(String[] args) {
EmployeeEarnings chart = new EmployeeEarnings();
chart.top();
chart.data();
}
}
+18
View File
@@ -0,0 +1,18 @@
import hsa.Console;
public class Lesson {
Console c;
public Lesson() {
c = new Console(24);
}
public void display() {
c.print(Math.pow(3, 2));
}
public static void main(String[] args) {
Lesson l = new Lesson();
l.display();
}
}
-31
View File
@@ -1,31 +0,0 @@
// Ian An
// Oct 15 2026
// User Input Assignment
import java.util.Scanner;
public class MyText {
public static void output() {
Scanner s = new Scanner (System.in);
String name;
String lastName;
int grade;
System.out.println("What is your first name?");
name = s.nextLine();
System.out.println("Hello "+name);
System.out.println("What is your last name");
lastName = s.nextLine();
System.out.println("Hello "+lastName);
System.out.println("What is your grade?");
grade = s.nextInt();
System.out.printf("So, %s %s, are you really in grade %d?",name,lastName,grade);
}
public static void main(String[] args) {
output();
}
}
+20
View File
@@ -0,0 +1,20 @@
import java.util.Scanner;
public class NumberRounder {
public NumberRounder() {}
public void display() {
Scanner scanner = new Scanner(System.in);
System.out.print("The number you want to round:");
double Number = scanner.nextDouble();
System.out.print("Round to the nearest 1, 10, 100, 1000:");
int round = scanner.nextInt();
System.out.printf("The rounded number is: %d", (int) (Number + 5) / round * round);
}
public static void main(String[] args) {
NumberRounder r = new NumberRounder();
r.display();
}
}
+29
View File
@@ -0,0 +1,29 @@
import java.util.Scanner;
public class PizzaBurner {
public PizzaBurner() {}
public void display() {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of pizza slices: ");
int slices = scanner.nextInt();
double caloriesPerSlice = 355.0;
double burnRatePerHour = 550.0;
double totalCalories = slices * caloriesPerSlice;
double totalHours = totalCalories / burnRatePerHour;
System.out.printf("Hours to burn off: %.2f %n", totalHours);
int totalMinutes = (int) Math.round(totalHours * 60);
int hours = totalMinutes / 60;
int minutes = totalMinutes % 60;
System.out.printf("That is around %d hours and %d minutes",hours,minutes);
}
public static void main(String[] args) {
PizzaBurner p = new PizzaBurner();
p.display();
}
}
+20
View File
@@ -0,0 +1,20 @@
import java.util.Scanner;
public class RectangleArea {
public RectangleArea() {}
public void display() {
Scanner scanner = new Scanner(System.in);
System.out.print("Length of the rectangle:");
int length = scanner.nextInt();
System.out.print("Width of the rectangle:");
int width = scanner.nextInt();
System.out.printf("The area of the rectangle is: %d", length*width);
}
public static void main(String[] args) {
RectangleArea r = new RectangleArea();
r.display();
}
}
-29
View File
@@ -1,29 +0,0 @@
public class VariablesAssignmentB {
VariablesAssignmentB() {
}
public void Title() {
System.out.println("Name Program");
}
public void name1(String first, String last) {
System.out.printf("%s %s %n",first.toLowerCase(), last.toUpperCase());
}
public void name2(String lastName) {
for (int i = 0; i < lastName.length(); i++) {
System.out.println(lastName.charAt(i));
}
}
public static void main(String[] args) {
String firstName = "Ian";
String lastName = "An";
VariablesAssignmentB x = new VariablesAssignmentB();
x.Title();
x.name1(firstName, lastName);
x.name2(lastName);
}
}
Binary file not shown.