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

davidesm

I'm trying to get started in this Java program: 1. Define the double variables name test1, test2, test3 2. Assign values three test scores to test1, test2, test3 (for example 98, 95, 97) 3. Calculate the average or test1, test2 and test3 I started with: double test1 = "98" double test2 = "95"; double test3 = "97"; and the program already tells me something is wrong.

  • one year ago
  • one year ago

  • This Question is Closed
  1. KonradZuse
    Best Response
    You've already chosen the best response.
    Medals 0

    double test1 = "98" is missing ';'

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

    it's a double. i.e. numbers with decimals trailing. 98 should be 98, not "98" it should be like this: double test1 = 98;

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

    correct, the "" mean it is being defined as a string. but you want a double integer value. so you do not need the "".

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

    :p you guys move fast :D.

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

    dw, but you are correct konrad, the first value is missing ;

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

    I always like to go slow with them :P. Make them learn it. technically we should also say 98.0d is the standard. Only Double, Floats, and Longs really are classified... You can find it here! http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

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

    I personally don't use d though...

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

    Additional question: I got program without errors, but my average displays 96.6666666667. How can I make it only display 96.7? I know how to do it in C++, but not in Java.

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

    decimalFormat or bigInteger

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