what is wrong with my java program

Anthony_83

Commendable
Mar 26, 2016
2
0
1,510
//Anthony Bahlman program 4
import javax.swing.JOptionPane;

public class kanokla

{

public static void main(String[] args)

{

String input, name,serv;
char type;
int accnum, daym, nightm, count, min;
input= "";

for (count = 1; count<= 5;count++)
{

input = JOptionPane.showInputDialog(null, "type R for Regular or P for Premium");
type = input.charAt(0);

while(type != 'R'|| type != 'r' && type != 'P' || type != 'p')

{
input = JOptionPane.showInputDialog(null, "please type R for Regular or P for Premium try again");
type = input.charAt(0);
}

if(type == 'R' || type == 'r')

{
input = JOptionPane.showInputDialog(null, "minutes:");
min = Integer.parseInt(input);
}
else
{
input = JOptionPane.showInputDialog(null, "minutes in the day:");
daym = Integer.parseInt(input);

input = JOptionPane.showInputDialog(null, "minutes in the night:");
nightm = Integer.parseInt(input);
}
}
}

}
 
Solution
Sounds like homework, if so go ask your professor

And just a hint, it's your character parser that's at fault, if you put in any character it's going to trigger. after all, P can never be r, so if it's P then !r triggers and if r then !P triggers!

Anthony_83

Commendable
Mar 26, 2016
2
0
1,510


well its not going to the if statement
it is a school program
its in a infinite loop
 
Sounds like homework, if so go ask your professor

And just a hint, it's your character parser that's at fault, if you put in any character it's going to trigger. after all, P can never be r, so if it's P then !r triggers and if r then !P triggers!
 
Solution