stapps
stapps
JCHJava Community | Help. Code. Learn.
Created by stapps on 10/5/2024 in #java-help
.length issue
No description
6 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 9/13/2024 in #java-help
Cants seem to get java to recognize a text file.
No description
58 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 3/27/2024 in #java-help
if statement problem
No description
65 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 3/25/2024 in #java-help
Practice problem with arrays issue
/*program asks the user to use specific keys to unlock specific keys, if the wrong key is used on the wrong key it explodes and ends the program */ import java.util.Scanner; public class Keygame { public static void main(String[] args){ Scanner input = new Scanner(System.in); String[] key = {"Skeleton key", "Stone key", "Wood key", "plastic key" }; System.out.println("Before you are 4 keys. \n Each key take a different key. \n You have each key in your bag but be careful. \n Using the wrong key will cause the key to explode.\n"); System.out.println("please type a number corresponding to the one beside each key \n"); for(int i = 0; i < key.length; i++){ System.out.println(i+1 + "." + key[i]); } int pkey = input.nextInt(); if(pkey >= 1 && pkey <= key.length){ int chosenkey = pkey - 1; System.out.println(" you chose " + key[chosenkey]); } else{ System.out.println("You have chosen the (INSTANT DEATH IF YOU CHOOSE IT key) \n you will now instantly die \n game over "); } String[] door = {"Skeleton door", "Stone door", "Wood door", "plastic door" }; System.out.println("\nplease type a number corresponding to the one beside each door"); for(int i = 0; i < door.length; i++){ System.out.println(i+1 + "." + door[i]); } int pdoor = input.nextInt(); if(pdoor >= 1 && pdoor <= door.length){ int chosendoor = pdoor - 1; System.out.println(" you chose " + door[chosendoor]); } else{ System.out.println("You have chosen the (INSTANT DEATH IF YOU CHOOSE IT key) \n you will now instantly die \n game over "); } // print out what key and door you have chosen System.out.println("you are unlocking the " + door + " with " + key); } } cant seem to figure out how to print out the arrays the user chooses, no matter what i do it either prints out the number of the array or the memory address.
6 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 3/3/2024 in #java-help
Method repeating issue
I'm trying to figure out how to repeat the method while having the new one add the new input to the previous input. I haven't been able to figure this out and have been stuck on it for a while. here's what I currently have currently public static void problem1(){ System.out.println("Problem 1"); //Code for problem 1 here. int Ans; // asks the user how many temperatures they would like to input do{ Scanner input = new Scanner(System.in); System.out.println("please input the temperatures in degrees farenheit"); int temp = input.nextInt(); int[] tempNum = new int[temp]; int total = temp+temp; int average = total/tempNum[temp]; if(temp < 32){ System.out.println(" temperatures are below freezing"); } else if(temp == 32){ System.out.println(" temperatures are freezing"); } else if(temp > 32){ System.out.println(" temperatures are above freezing"); } System.out.println("The average is " + average); System.out.println("Would you like to input another temperature? Type 1 for yes and 2 for no"); Ans = input.nextInt(); //asks if the user would like to input another temp if(Ans == 2){ System.out.println("thank you and goodbye"); // shuts off when user inputs 2 System.exit(0); } else if( Ans > 2){ System.out.println("Please input a valid option"); System.exit(0); } } while(Ans == 1); // loops when user inputs 1 }
15 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 5/17/2023 in #java-help
wont read files?
No description
4 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 5/17/2023 in #java-help
next() problem
No description
21 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 5/17/2023 in #java-help
integers only problem
No description
7 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 5/17/2023 in #java-help
InputMismatchException problem
No description
8 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 5/10/2023 in #java-help
Name program problems
No description
11 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 4/23/2023 in #java-help
learning graphics problem
No description
5 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 4/12/2023 in #java-help
Arrays.toString() not working?
No description
81 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 4/9/2023 in #java-help
question about second for loop
No description
7 replies
JCHJava Community | Help. Code. Learn.
Created by stapps on 3/31/2023 in #java-help
Having trouble with this excercise on consuming tokens I am trying studying
No description
22 replies