Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

WilsonWorla Group Title

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
  1. larrymud Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    remove the semicolon after if(books>=3)

    • one year ago
  2. larrymud Group Title
    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,.

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

    Above comment should read: reverse the order of if statements

    • one year ago
  4. larrymud Group Title
    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);

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

    This get bumped for a reason? Still need help?

    • 11 months ago
    • Attachments:

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