Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
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?
 one year ago
 one year 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?
 one year ago
 one year ago

This Question is Open

larrymudBest ResponseYou've already chosen the best response.0
remove the semicolon after if(books>=3)
 one year ago

larrymudBest ResponseYou've already chosen the best response.0
also: 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,.
 one year ago

larrymudBest ResponseYou've already chosen the best response.0
Above comment should read: reverse the order of if statements
 one year ago

larrymudBest ResponseYou've already chosen the best response.0
int 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);
 one year ago

e.mccormickBest ResponseYou've already chosen the best response.0
This get bumped for a reason? Still need help?
 6 months ago
See more questions >>>
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.