HOW DO I ADD TRY CATCH STATEMENTS TO THIS PIECE OF CODE SO THE APPLICATION DOES NOT CRASH
case 4: //switch profiles
if(nop <= 1){
System.out.println("Theres no profiles to switch to");
break;
}
else{
System.out.println("Please select a profile");
int
switchpro = Integer.parseInt(sc.nextLine());
if(switchpro > 0 && switchpro <= nop){
index = switchpro-1;
}
else{
System.out.println("Invaild, please select a
vaild profile");
}
break;
}
case 4: //switch profiles
if (nop <= 1) {
System.out.println("Theres no profiles to switch to");
break;
} else {
System.out.println("Please select a profile");
try {
int switchpro = Integer.parseInt(sc.nextLine());
if (switchpro > 0 && switchpro <= nop) {
index = switchpro - 1;
} else {
System.out.println("Invaild, please select a vaild profile");
}
} catch (Exception e) {
System.out.println("Invaild, please select a vaild profile");
}
break;
}
HOW DO I ADD TRY CATCH STATEMENTS TO THIS PIECE OF CODE SO THE APPLICATION DOES...
Having trouble with a Zoo Monitoring system. Using NetBeans. i have worked out most of the bugs but now its only printing the first few lines of the text file (it prints the lines that begin with "Details" and not continuing to the rest to find the lines with ***** in them to pop up the Joption pane with the alert for that line. below is the code for both java files, as well as the .txt files its reading...
How would this switch statement be modified to not use "continue"? This piece of code is part of a larger assignment and that assignment prohibits the use of "continue" for switch statements. How do I modify this code so that it still does what I want it to do, without using "continue"? while (true) { choice = displayMenu(keyboard); switch (choice) { case 'D': case 'd': { courseStudents.displayStudentList(); continue; } case 'A': case 'a': { int id; double stGpa; System.out.println("Enter...
Here is my skeleton code to this C# assignement I need to add a few things, Change the the switch to If and Else-If statements (and test it is still working here) Add a third "Submit" button called SubmitButton In your If and Else-If add a condition if city is Honolulu and SubmitButton is checked. Display "Honolulu is the best place to be this time of year! I wish I was there!". Add comments, including header. HELP PLEASE ASAP public...
Debug and fix the Java console application that uses 2 dimensional arrays but the application does not compile nor execute. Student enters only integers to select courses for registration from a menu. No data type validation of the user menu selection is checked or required. The program terminates only when the student closes it. No registration of other courses not displayed by the program . No registration more than once for the same course. No registration for more than 9...
Can you help me rearrange my code by incorporating switch I'm not really sure how to do it and it makes the code look cleaner. Can you help me do it but still give the same output? Also kindly add an in-line comment on what changes and rearrangement you've done so I can understand what's going on. import java.util.ArrayList; import java.util.Scanner; public class Bank { /** * Add and read bank information to the user. * @param arg A string,...
I need help solving this assignment, you are given a full piece of code that does not run correctly. Some of the bugs can be found at compile time, while others are found at run time. Access the UserMenu.cpp code file (in the zip file in Start Here) and use debugging practices and the debugger in Visual Studio to find each bug. Fix the bug and write a comment in the code giving a description of how you found the...
Can you modify this code so that it display the number of coins and subtotal for each type of coin(dimes, penny, quarter, nickel) and the total value in the wallet. But still reads the data from file coins.txt. Which is below MyCode. The original question was this: Two classes are given: Coin and Wallet. Write an application named MyWallet.java that reads all coins from a data file named coins.txt. The first line in the data file contains the number of...
For this code after case 0, I need it to ask the user if they would like to see the menu again and some type of if statement or loop to ask them yes or no and if yes print again and if no end program. So it would ask if they would like to see the menu again then ask what their choice is. If yes print menu and if no end program. import java.util.InputMismatchException; import java.util.*; import java.io.*;...
Hi. This is a prototype of Java. The following Java program was developed for prototyping a mini calculator. Run the program and provide your feedback as the user/project sponsor. (Save the code as MiniCalculator.java; compile the file: javac MiniCalculator.java; and then run the program: java MiniCalculator). HINTs: May give feedback to the data type and operations handled by the program, the way the program to get numbers and operators, the way the calculation results are output, the termination of the...
THIS IS MY CODE ALL I NEED IS THE SECTIONS TO BE FILLED IN AND CODE SHOULD RUN. FILL IN THE CODE PLEASE. package p02; import static java.lang.System.*; import java.io.*; import java.util.*; public class P02 { public static Vector<Double> wallet=new Vector<Double>(); public static void addMoneyToWallet(){ } public static void removeMoneyFromWallet(){ } public static void displayMoneyInWallet(){ } public static void emptyWallet(){ } public static void main(String[] args){ int choice=0; String menu="Wallet...