• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trying to make a grading program loop to start from the beginning

 
Ranch Hand
Posts: 47
Netbeans IDE Chrome Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:Two things you still need to do:

* Remove variables A, B, C, and F.  They are not used
* Reformat the code.  In netbeans, as in other IDEs, this is a simple key combination (that I have forgotten).




 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great! (Line 31 needs to be indented, but that's minor).

Now I believe that Carrey suggested that you prompt three times for the three grades, and I agree.

Something else to think about: what happens if a user enters "A" for the grade?  How can you prevent it?  How can using a different prompt help prevent this?
 
Marshal
Posts: 8853
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a bit disappointed that @OP is satisfied with such his approach solving this exercise.

I was studying myself and I know that having everything so chaotic leads nowhere. Better code organization is expected right from the 1st day of Introduction to Programming course. Meaning no prior experience is needed, but better code organization *is* expected. And that is not because somebody requires like that, that is because *that way* is much easier to solve problems.

1. All the comments you have aren't useful. And in some places - misleading. An example:

So what we see here. My guess is that OP's comments referring to the preceding lines. However, if you look closely, this comment is nonsense. I'll leave for OP to figure out what is wrong there.

2. Very first line says Averages5.java, yet the class declaration says it is Averages7. That shows how such comments go out of date in a blink of an eye. So better not to have such comments which say nothing and usually say wrong.

3. Snippet below:
@OP You don't need all these && operators. Think how you could simplify this code. i.e.:

4. Did you learn methods yet? Anyway, since you already using them, i.e.: main(), I'd suggest start organizing your program into methods, where each method does one thing and one thing only. i.e.:

Every little detail is important. You need to take control of your code and don't let the chaotic code ruin your project.
 
Marshal
Posts: 79072
376
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:. . .. . . .

I would do it the other way round. If the boundary value (80 or 70) is included in the upper grade, I would start small, and I would use the < operator because I think it is easier to read than ≥ or >=Note the last option is a plain simple else. My grades are different from OP's.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic