what is wrong with my java program

Anthony_83

Commendable
Mar 26, 2016
2
0
1,510
0
//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);
}
}
}

}
 

Anthony_83

Commendable
Mar 26, 2016
2
0
1,510
0


well its not going to the if statement
it is a school program
its in a infinite loop
 

basroil

Honorable
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!
 
Thread starter Similar threads Forum Replies Date
A Apps General Discussion 1
O Apps General Discussion 6
A Apps General Discussion 2
Z Apps General Discussion 8
D Apps General Discussion 5
L Apps General Discussion 1
B Apps General Discussion 3
A Apps General Discussion 2
A Apps General Discussion 13
B Apps General Discussion 2
D Apps General Discussion 1
S Apps General Discussion 2
V Apps General Discussion 1
S Apps General Discussion 4
L Apps General Discussion 8
A Apps General Discussion 1
derpmaster Apps General Discussion 6
L Apps General Discussion 2
A Apps General Discussion 4
S Apps General Discussion 3

ASK THE COMMUNITY