For some reason i get:
When i try to compile this:Code:ryan@ryan-desktop:~/Documents/Programs/Java_Programming/Labs_1068/Lab_4$ javac Server.java Server.java:78: variable a might not have been initialized System.out.println("gcd(" + a + ", " + b + ") = " + Client.gcd(a, b)); ^ Server.java:78: variable b might not have been initialized System.out.println("gcd(" + a + ", " + b + ") = " + Client.gcd(a, b)); ^ Server.java:106: variable a might not have been initialized System.out.println("MaxFactor(" + a + ", " + b + ") = " + Client.maxFactor(a, b)); ^ Server.java:106: variable b might not have been initialized System.out.println("MaxFactor(" + a + ", " + b + ") = " + Client.maxFactor(a, b)); ^ Server.java:131: variable a might not have been initialized Client.fibonaci(a); ^ Server.java:156: variable a might not have been initialized System.out.println("aPower(" + a + ") = " + Client.aPower(a)); ^ Server.java:181: variable a might not have been initialized System.out.println("aPowerOf2(" + a + ") = " + Client.aPowerOf2(a));
Any help would be greatly appreciated. Thank you.Code:import java.util.*; public class Server { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int Case = 0; int Counter = 1; int Counter_2 = 1; int Counter_3 = 1; int a, b, m; System.out.println("Welcome to the Math Wizard!"); while(Counter == 1) { System.out.println(); System.out.println("If you would like to find the greatest common divisor ENTER 1."); System.out.println("If you would like to find the Max Factor ENTER 2."); System.out.println("If you would like to find the Fibonaci sequence ENTER 3."); System.out.println("If you would like to find what your number is the power of ENTER 4."); System.out.println("If you would like to find out what power of two your number is ENTER 5."); System.out.println("If you would like to leave the program now ENTER 6.\n"); Counter_2 = 1; Counter_3 = 1; while(Counter_2 == 1) { try { System.out.print("Please enter your number: "); Case = scan.nextInt(); m = 0; } catch(InputMismatchException e) { scan.next(); System.out.println("Not a numeric character!"); System.out.println("Please try again!"); m = 1; } if(m == 1) ; else Counter_2 = 2; } switch(Case) { case 1: { while(Counter_3 == 1) { try { System.out.println("Please enter two numbers: "); System.out.print("a = "); a = scan.nextInt(); System.out.print("b = "); b = scan.nextInt(); m = 0; } catch(InputMismatchException e) { scan.next(); System.out.println("Not a numeric character!"); System.out.println("Please try again!"); m = 1; } if(m == 1) ; else Counter_2 = 2; } System.out.println("gcd(" + a + ", " + b + ") = " + Client.gcd(a, b)); break; } case 2: { while(Counter_3 == 1) { try { System.out.println("Please enter two numbers: "); System.out.print("a = "); a = scan.nextInt(); System.out.print("b = "); b = scan.nextInt(); m = 0; } catch(InputMismatchException e) { scan.next(); System.out.println("Not a numeric character!"); System.out.println("Please try again!"); m = 1; } if(m == 1) ; else Counter_2 = 2; } System.out.println("MaxFactor(" + a + ", " + b + ") = " + Client.maxFactor(a, b)); break; } case 3: { while(Counter_3 == 1) { try { System.out.print("Please enter one number: "); a = scan.nextInt(); m = 0; } catch(InputMismatchException e) { scan.next(); System.out.println("Not a numeric character!"); System.out.println("Please try again!"); m = 1; } if(m == 1) ; else Counter_2 = 2; } Client.fibonaci(a); break; } case 4: { while(Counter_3 == 1) { try { System.out.print("Please enter one number: "); a = scan.nextInt(); m = 0; } catch(InputMismatchException e) { scan.next(); System.out.println("Not a numeric character!"); System.out.println("Please try again!"); m = 1; } if(m == 1) ; else Counter_2 = 2; } System.out.println("aPower(" + a + ") = " + Client.aPower(a)); break; } case 5: { while(Counter_3 == 1) { try { System.out.print("Please enter one number: "); a = scan.nextInt(); m = 0; } catch(InputMismatchException e) { scan.next(); System.out.println("Not a numeric character!"); System.out.println("Please try again!"); m = 1; } if(m == 1) ; else Counter_2 = 2; } System.out.println("aPowerOf2(" + a + ") = " + Client.aPowerOf2(a)); break; } default: { System.out.println("\nThank you for using Math Wizard!"); System.out.println("Have a nice day!"); Counter = 2; break; } } } } }




Reply With Quote