Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Need help with homework (beginner)

  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Need help with homework (beginner)

    Edit: Guess you wont do my homework sorry for bother.
    Last edited by JavaPotato; October 6th, 2014 at 05:46 PM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Need help with homework (beginner)

    Which part of this is giving you trouble? What have you tried so far?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with homework (beginner)

    Ok i tried to make a code.
    I need program that gives u what deegre u have when u enter how much score u have. Can i do it with switch or i must do it with if else?

    import java.util.Scanner;
     
    public class Main
    {
         public static void main(String [] args){
           Scanner scanner = new Scanner(System.in);
     
           System.out.println("Enter number of score:");
           int number = scanner.nextInt();
     
           String score = "";
     
           switch(number){
               case 0-50:  score="F"; break;
               case 51-59: score="E"; break;
               case 60-69: score="D"; break;
               case 70-79: score="C"; break;
               case 80-89: score="B"; break;
               case 90-100: score="A"; break;
               default: score="Wrong score"; break;
           }
     
           System.out.println(score);
        }
    }

    Can u help me with case i dont know what to put there where are numbers now.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Need help with homework (beginner)

    A switch statement is used for single values like 1,2 3, etc. If you want to test for a range of values (1 to 5, 6 to 10, etc), an if/else if chain would be better.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Oct 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need help with homework (beginner)

    ok ty guess its something like this

    if (grade > 90 && grade <= 100) {
    grade= 'A';
    } else if (grade > 80 && grade <= 89) {
    grade= 'B';
    } else if (grade > 70 && grade <= 79) {
    grade= 'C';
    } else if (grade > 60 && grade <= 69) {
    grade= 'D';
    } else if (grade> 0 && grade <= 59) {
    grade= 'F';
    }
    System.out.print( grade);

    will try

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Need help with homework (beginner)

    ok
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [Beginner] Need Help for my Homework
    By deluxe7 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 12th, 2014, 06:04 PM
  2. Homework Help Java Beginner
    By Edmacelroy in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 21st, 2013, 04:39 PM
  3. Beginner struggling with homework question
    By mets3214 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 6th, 2013, 08:10 PM
  4. Help with homework
    By gta1 in forum Object Oriented Programming
    Replies: 1
    Last Post: March 11th, 2013, 08:58 PM
  5. Homework assignment (beginner)
    By z3ohyr84 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 30th, 2011, 01:32 PM