Sorry for this guys, but I really am unlucky today. Please help, my problem a while ago was that I'm having problems while looping, and now it cannot loop at all. It won't let me enter the string to make it loop. Name, and year and section also outputs as null. I also tried using try catch but it doesn't seem to be picking up any errors. Here's the whole program. It just terminates, exactly on:
enter 1 to continue;
import java.util.*;
public class program
{
public static Scanner rew= new Scanner(System.in);
public static String name, yearandsec;
public static char sex_code;
public static int scode;
public static double seq;
public static int ccode;
public static int units;
public static double fee_per_unit;
public static double misc;
public static double gross;
public static String dec;
public static String decision;
public static void main(String[] args) {
String dec;
do {
System.out.println("Input info:");
String name = stringGetter("Name: ");
String yearandsec = stringGetter("Year and section: ");
sex_code=charGetter("Sex code: " + "\n" + "[M]" + "\n" + "[F]:");
scode=intGetter("Scholarship code: ");
ccode=intGetter("Course code: ");
units=intGetter("Units: ");
fee_per_unit=doubleGetter("Fee per unit: ");
misc=doubleGetter("Miscellaneous: ");
display();
switches(scode, units, fee_per_unit, misc);
dec = stringGetterz("Enter 1 to continue: ");
} while(dec.equals("1"));
}
public static String stringGetterz(String ny){
System.out.println(ny);
return rew.nextLine();
}
public static char charGetter(String cg){
String sc;
char cc;
System.out.print(cg);
sc=rew.nextLine();
cc=sc.charAt(0);
return cc;
}
public static void switches(int scholar, int u, double fpu, double mi){
double discnt=0;
switch(scholar){
case 1:
System.out.println("Scholarship: Full Scholar..");
discnt=1;
break;
case 2:
System.out.println("Scholarship: Half Scholar..");
discnt=.50;
break;
case 3:
System.out.println("Scholarship: Dean's Lister..");
discnt=.15;
break;
case 4:
System.out.println("Scholarship: None..");
discnt=0;
break;
}
double gf;
double disc;
disc =(u * fpu) *discnt;
gf=(u * fpu) + mi - disc;
System.out.println(gf);
}
public static void switchcase(char gender, int corz){
double discnt=0;
switch(gender){
case 'M':
case 'm':
System.out.println("Sex: Male");
break;
case 'F':
case 'f':
System.out.println("Sex: Female");
break;
}
switch(corz){
case 1:
System.out.println("Course: BSIT...");
break;
case 2:
System.out.println("Course: BSCS..");
break;
case 3:
System.out.println("Course: BSCOE..");
break;
}
}
public static void display(){
System.out.println("Name: " + name + "\n" + "Year and Section: " + yearandsec);
System.out.println("Units enrolled: " + units + "\n" + "Fee per unit: " + fee_per_unit + "\n" + "Miscellaneous: " + misc);
switchcase(sex_code, ccode);
}
public static double doubleGetter(String dg){
double fm;
System.out.println(dg);
fm=rew.nextDouble();
return fm;
}
public static int intGetter(String scu){
int iget;
System.out.println(scu);
iget=rew.nextInt();
return iget;
}
public static String stringGetter(String ny){
String sget;
System.out.println(ny);
sget=rew.nextLine();
return sget;
}
}