Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

WilsonWorla

  • 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?

  • This Question is Open
  1. larrymud
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    remove the semicolon after if(books>=3)

  2. larrymud
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 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,.

  3. larrymud
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Above comment should read: reverse the order of if statements

  4. larrymud
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 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);

  5. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    This get bumped for a reason? Still need help?

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find 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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.