writing a java program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arishma
    New Member
    • Sep 2007
    • 4

    #1

    writing a java program

    a program that expects a numeric grade as input and outputs the corresponding letter grade. the program uses the following grading scale:
    numeric range letter grade
    0 39 E
    40 49 D
    50 56 C
    57 63 C+
    64 70 B
    71 77 B+
    78 84 A
    85 100 A+

    required to use compound boolean operators
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by arishma
    a program that expects a numeric grade as input and outputs the corresponding letter grade. the program uses the following grading scale:
    numeric range letter grade
    0 39 E
    40 49 D
    50 56 C
    57 63 C+
    64 70 B
    71 77 B+
    78 84 A
    85 100 A+

    required to use compound boolean operators
    Hi Arishma! Welcome to TSDN!
    Check out the java.util.Scann er class for reading in your numeric value and then find the correct Letter for it. If you're new to Java, check out this article - it will teach you, what you have to know to solve this problem.

    Greetings,
    Nepomuk

    Comment

    • nickyeng
      Contributor
      • Nov 2006
      • 252

      #3
      hi,

      why not you give some code that you've done to show us what you've got so far..

      but you seems like asking ppl giving you the code...

      :p

      from
      Nick.

      Comment

      • arishma
        New Member
        • Sep 2007
        • 4

        #4
        [CODE=java]import java.io.*;
        class testscore {
        public static void main(String[] args) {

        int testscore;
        char Grade;
        char Grade;//To print the student grade on the screen

        if (testscore >=0 && testscore <= 39)
        System.out.prin tln( "E" ) ;
        if (testscore >= 40 && testscore <= 49)
        System.out.prin tln( "D" ) ;
        if (testscore >= 50 && testscore <=56)
        System.out.prin tln( "C" ) ;
        if (testscore >= 57 && testscore <=63)
        System.out.prin tln( "C+" ) ;
        if (testscore >=64 && testscore <= 70)
        System.out.prin tln( "B" ) ;
        if (testscore >=71 && testscore <= 77)
        System.out.prin tln( "B+" ) ;
        if (testscore >=78 && testscore <= 84)
        System.out.prin tln( "A" ) ;
        if (testscore >= 85 && testscore <= 100)
        System.out.prin tln( "A+" ) ;


        return Grade;//method to return student grade
        }

        }
        [/CODE]

        this is what i have got but 1 error where help pliz
        Last edited by r035198x; Sep 6 '07, 06:40 AM. Reason: added the missing code tags

        Comment

        • arishma
          New Member
          • Sep 2007
          • 4

          #5
          thanx a ton i think i have got it now

          Comment

          • Nepomuk
            Recognized Expert Specialist
            • Aug 2007
            • 3111

            #6
            Originally posted by arishma
            thanx a ton i think i have got it now
            Well done for finding it!

            One little tip:
            When you ask for help next time, don't just state, that there is an error, but also tell us, what error it is (what it is called, e.g. NullPointerExce ption, IOException, ...) and in what line it occurs (the compiler will write something like
            [CODE=java]Exception in thread "main" java.lang.NullP ointerException
            at java.io.FileInp utStream.<init> (Unknown Source)
            at yourProject.you rClass.main(Exc eptions.java:12 )
            [/CODE]and then 12 would be the line you're looking at).

            Greetings,
            Nepomuk

            Comment

            Working...