Question:

In java how do you make it were a person enters 98 and it comes out as an a

by  |  earlier

0 LIKES UnLike

the scanner gets the number for example "87, 89, or 88.8"

and it prints out "b average"

 Tags:

   Report

5 ANSWERS


  1. Please post your source-code so that we can help you better.


  2. So I assume this is a Grading System ( enter marks to get the exam grade) instead of typecasting numbers to ASCII code..

    u could use switch case;

    let see,

    to get input from user, we import this library:

    import java.util.*;

    class grading{

         int mark;

        String getGrade()

       {

           if(mark>=90)

              return "A good";

          else if(mark<90 && mark >=80)

             return "B average";

       }

        public static void main(String args[])

       {

            Scanner scan = new Scanner(System.in);

            grading mymark = new grading();

            mymark.mark = scan.nextInt();    // prompt user for input

            System.out.println(mymark.getGrade()); // print the result

       }

    }

        

    this is just the sample... if u want more grades.. u could define more inside the getGrade() method....

          


  3. I'm not very good at Java, but from experience with other coding languages, it can be done with this (please translate to Java):

    var string = YOUR GRADE HERE;

    if (string >=87 && string <=89) {

      echo "b average";

    }

    and so on. Sorry for not knowing Java directly, but it should translate easily.

    You could take a look at this:

    http://72.5.124.55/docs/books/tutorial/j...

  4. can you clear your question more

  5. i dont know Java but I do know other programming languages similar so i would assume the algorithm is the same

    var Grade1=87;

    var Grade2=89;

    var Grade3=88.8;

    var Total = (Grade1+Grade2+Grade3)/3;

    //Finds the average

    if (Total < 90 && Total > 80)

    print "B Average";

    else

    print "not B average";

Question Stats

Latest activity: earlier.
This question has 5 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.