A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 3 years ago
import javax.swing.JOptionPane;
public class BookClubPoint {
public static void main(String[] args) {
// TODO code application logic here
String A = "You have earned 0 points";
String B = "You have earned 5 points";
String C = "You have earned 15 points";
String D = "You have earned 30 points";
String E = "Yo have earned 60 points";
int points;
String Bkacess =JOptionPane.showInputDialog(null,"Enter the number of books: ");
int books = Integer.parseInt(Bkacess);
if( books >= 0)
JOptionPane.showMessageDialog(null, A );
else
if( books >= 1 )
JOptionPane.showMessageDialog(null, B );
else
if ( books >= 2 )
JOptionPane.showMessageDialog(null,C);
else
if ( books >= 3);
JOptionPane.showMessageDialog(null,D);
else
JOptionPane.showMessageDialog(null, E);
}
}
my code doesn't run, why?
anonymous
 3 years ago
import javax.swing.JOptionPane; public class BookClubPoint { public static void main(String[] args) { // TODO code application logic here String A = "You have earned 0 points"; String B = "You have earned 5 points"; String C = "You have earned 15 points"; String D = "You have earned 30 points"; String E = "Yo have earned 60 points"; int points; String Bkacess =JOptionPane.showInputDialog(null,"Enter the number of books: "); int books = Integer.parseInt(Bkacess); if( books >= 0) JOptionPane.showMessageDialog(null, A ); else if( books >= 1 ) JOptionPane.showMessageDialog(null, B ); else if ( books >= 2 ) JOptionPane.showMessageDialog(null,C); else if ( books >= 3); JOptionPane.showMessageDialog(null,D); else JOptionPane.showMessageDialog(null, E); } } my code doesn't run, why?

This Question is Open

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0remove the semicolon after if(books>=3)

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0also: string E should start with "You" not Yo. also: your first test will be true for any number of books so you will always get 0 points. Reverse the order of books or use a switch statement that defaults to max points,.

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0Above comment should read: reverse the order of if statements

anonymous
 3 years ago
Best ResponseYou've already chosen the best response.0int books = Integer.parseInt(Bkacess); if( books > 3) JOptionPane.showMessageDialog(null, E); else if( books == 3 ) JOptionPane.showMessageDialog(null,D); else if ( books == 2 ) JOptionPane.showMessageDialog(null,C); else if ( books == 1) JOptionPane.showMessageDialog(null, B ); else JOptionPane.showMessageDialog(null,A);

e.mccormick
 2 years ago
Best ResponseYou've already chosen the best response.0This get bumped for a reason? Still need help?
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.