Reset author name to chosen name ✨
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.mp1_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class CompoundValue {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// Create Scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Define vars
|
||||
int counter;
|
||||
double SavingAmount;
|
||||
double InterestRate;
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Enter monthly saving amount: ");
|
||||
SavingAmount = input.nextDouble();
|
||||
|
||||
// Compute and Print result
|
||||
InterestRate = 0.05 / 12;
|
||||
SavingAmount = SavingAmount * (1 + InterestRate);
|
||||
System.out.println("The account is " + SavingAmount + " after month 1");
|
||||
for (counter = 2; counter <= 6; counter++) {
|
||||
SavingAmount = (100 + SavingAmount) * (1 + InterestRate);
|
||||
System.out.println("The account is " + SavingAmount + " after month " + counter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.mp1_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Cylinder {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Enter radius of the cylinder
|
||||
System.out.print("Enter the radius and length of a cylinder: ");
|
||||
double radius = input.nextDouble();
|
||||
double length = input.nextDouble();
|
||||
|
||||
// Compute area and volume
|
||||
double area = radius * radius * 3.14159;
|
||||
double volume = area * length;
|
||||
|
||||
// Display result
|
||||
System.out.println("The area is " + area);
|
||||
System.out.println("The volume of the cylinder is " + volume);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template
|
||||
*/
|
||||
|
||||
package com.chloefontenot.mp1_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class MP1_ChloeFontenot {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.mp1_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class NumberOfYears {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Define vars
|
||||
double NumberOfMinutes;
|
||||
double NumberOfYears;
|
||||
double NumberOfDays;
|
||||
double NumberOfHours;
|
||||
|
||||
// Create Scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Prompt for input
|
||||
System.out.print("Enter the number of minutes: ");
|
||||
NumberOfMinutes = input.nextDouble();
|
||||
|
||||
// Calculate
|
||||
NumberOfHours = (NumberOfMinutes / 60);
|
||||
NumberOfDays = (NumberOfHours / 24);
|
||||
NumberOfYears = (NumberOfDays / 365);
|
||||
|
||||
// Big brain math time
|
||||
//Subtract 365 from "NumberOfDays" until the number is less than or equal to 365
|
||||
while (NumberOfDays >= 365.0) {
|
||||
//System.out.println("DEBUG: Subtracting 365 from "+ NumberOfDays);
|
||||
NumberOfDays = NumberOfDays - 365;
|
||||
}
|
||||
|
||||
// Do the same with hours
|
||||
while (NumberOfHours >= 24.0) {
|
||||
//System.out.println("DEBUG: Subtracting 24 from "+ NumberOfHours);
|
||||
NumberOfHours = NumberOfHours - 24;
|
||||
}
|
||||
|
||||
// Print output
|
||||
System.out.println((int) NumberOfMinutes + " minutes is approx. :");
|
||||
if ((int)NumberOfYears >= 2) {
|
||||
System.out.println((int) NumberOfYears + " years,");
|
||||
}
|
||||
if ((int)NumberOfYears == 1) {
|
||||
System.out.println((int)NumberOfYears+" year.");
|
||||
}
|
||||
if ((int) NumberOfDays != 0) {
|
||||
System.out.println((int) NumberOfDays + " days,");
|
||||
}
|
||||
if ((int) NumberOfHours != 0) {
|
||||
System.out.println((int) NumberOfHours + " hours.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.mp1_chloefontenot;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class SumOfDigits {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
java.util.Scanner input = new java.util.Scanner(System.in);
|
||||
//> Read a number
|
||||
System.out.print("Inter an integer between 0 and 1000: ");
|
||||
int number = input.nextInt();
|
||||
|
||||
//> Find all digits in number
|
||||
int lastDigit = number % 10;
|
||||
int remainingNumber = number / 10;
|
||||
int secondLastDigit = remainingNumber % 10;
|
||||
remainingNumber = remainingNumber / 10;
|
||||
int thirdLastDigit = remainingNumber % 10;
|
||||
|
||||
//> Obtain the sum of all digits
|
||||
int sum = lastDigit + secondLastDigit + thirdLastDigit;
|
||||
|
||||
//>Display results
|
||||
System.out.println("The sum of all digits in "+ number
|
||||
+ " is " + sum);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.mp1_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class Total {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Define variables:
|
||||
double subtotal;
|
||||
double gratuity;
|
||||
double total;
|
||||
|
||||
// Get subtotal and gratuity rate
|
||||
// Setup Scanner
|
||||
Scanner input = new Scanner(System.in);
|
||||
|
||||
// Get vars
|
||||
System.out.print("Enter subtotal and gratuity rate: ");
|
||||
subtotal = input.nextDouble();
|
||||
gratuity = input.nextDouble();
|
||||
|
||||
// Calculate
|
||||
// Convert gratuity into a decimal because its a percentage:
|
||||
gratuity = (gratuity / 10); //* 10;
|
||||
|
||||
total = (subtotal + gratuity);
|
||||
|
||||
// Print result
|
||||
System.out.println("The gratuity is $"+gratuity+" and the total is $"+total);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package com.chloefontenot.mp1_chloefontenot;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chloe
|
||||
*/
|
||||
public class WindChill {
|
||||
public static void main(String[] args) {
|
||||
Scanner input = new Scanner(System.in);
|
||||
//> Enter the new temperature in Fahrenheit
|
||||
System.out.print("Enter the temperature in Fahrenheit between -58∞F and 41∞F: ");
|
||||
double fahrenheit = input.nextDouble();
|
||||
|
||||
//> Enter the wind speed miles per hour
|
||||
System.out.print("Enter the wind speed miles per hour "+
|
||||
"(must be greater or equal to 2):");
|
||||
double speed = input.nextDouble();
|
||||
|
||||
//> Compute wind and chill index
|
||||
double windChillIndex = 35.74 + 0.6215 * fahrenheit - 35.75
|
||||
* Math.pow(speed, 0.16) + 0.4275 * fahrenheit
|
||||
* Math.pow(speed, 0.16);
|
||||
|
||||
//> Display the result
|
||||
System.out.println("The wind chill index is "+ windChillIndex);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user