Possible Solutions for the Goals: Possible Goal Solution for Topic #1 Print Statements:
public class Main {
public static void main(String[] args) {
System.out.println("My name is " + "Aarav!");
System.out.println("Oh no! I just found a monster!");
System.out.println("Let me take out my katana! Takes out katana");
System.out.println("With one sweep of my sword, I slayed it!");
System.out.println("But there are more coming!!!");
//these two lines below are not needed but shown to implement .print()
System.out.print("That is the ");
System.out.println("END");
}
}Possible Goal Solution for Topic #3 Variable:
public class Main {
public static void main(String[] args) {
String username = "coolturtle7";
String password = "verySecretPa$$wor!!!!";
int age = 27;
double balance = 3289.29;
boolean inDebt = false;
System.out.println("Your username is " + username);
System.out.println("Your password is " + password);
System.out.println("Your age is " + age);
System.out.println("Your balance is " + balance);
System.out.println("You are in debt: " + inDebt);
}
}Possible Goal Solution for Topic #4 If-statements:
public class Main {
public static void main(String[] args) {
double grade = 87.2;
if(grade < 80){
System.out.println("You have a C");
} else{
if(grade < 90){
System.out.println("You have a B");
} else{
System.out.println("You have an A!!!");
}
}
}
}Possible Goal Solution for Topic #5 (Extension) Scanner:
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("What is your desired username?");
String username = scanner.nextLine();
System.out.println("What is your desired password?");
String password = scanner.nextLine();
int age = 27;
double balance = 3289.29;
System.out.println("Your current balance is " + balance + ". If you want to withdraw money, type 0. If you want to add money, type 1");
if(scanner.nextInt() == 0){
System.out.println("How much money do you want to withdraw?");
balance = balance - scanner.nextDouble();
} else{
System.out.println("How much money do you want to add?");
balance = balance + scanner.nextDouble();
}
boolean inDebt = false;
System.out.println("Your username is " + username);
System.out.println("Your password is " + password);
System.out.println("Your age is " + age);
System.out.println("Your balance is " + balance);
System.out.println("You are in debt: " + inDebt);
}
}Possible Goal Solution for Topic #6 (Extension) Methods:
public class Main {
public static void addToBalance(double balance){
Scanner scannerTwo = new Scanner(System.in);
System.out.println("How much money do you want to add?");
balance = balance + scannerTwo.nextDouble();
}
public static void checkCredentials(String password){
if(password.equals("password"){
System.out.println("You password is not safe!");
} else{
System.out.println("Your password is secure");
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("What is your desired username?");
String username = scanner.nextLine();
System.out.println("What is your desired password?");
String password = scanner.nextLine();
int age = 27;
double balance = 3289.29;
System.out.println("Your current balance is " + balance + ". If you want to withdraw money, type 0. If you want to add money, type 1");
if(scanner.nextInt() == 0){
System.out.println("How much money do you want to withdraw?");
balance = balance - scanner.nextDouble();
} else{
addToBalance(balance);
}
boolean inDebt = false;
System.out.println("Your username is " + username);
System.out.println("Your password is " + password);
System.out.println("Your age is " + age);
System.out.println("Your balance is " + balance);
System.out.println("You are in debt: " + inDebt);
}
}