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 2 of 2

Thread: How to input exam score using for loop statement

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Location
    Butuan city
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to input exam score using for loop statement

    [B]import java.util.Scanner;
    public class examscore {
    static int score=new int [10];
    public static Scanner a=new Scanner(System.in);
    public static void main(String args[]){
    input(a);
    sort(10);
    }
    public static void input(Scanner a){
    System.out.print("Enter ten exam scores:");
    for(int i=0; i<10;i++)
    scores[i]=a.nextInt();
    }
    public static void main sort(int x){
    for(int i=0;i<x;i++)
    for(int j=0;i<j;j++){


    if(scores[i]>scores[i])

    int temp=scores[i];
    scores[i]=scores[j];
    scores[j]=temp;
    }
    for(int j=0;j<x;j++)
    System.out.println(scores[j]);
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,661
    Thanks
    45
    Thanked 1,960 Times in 1,934 Posts

    Default Re: How to input exam score using for loop statement

    Did you have any questions about the code?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] A Loop statement and a switch statement issue
    By sternfox in forum Loops & Control Statements
    Replies: 13
    Last Post: March 7th, 2013, 03:19 PM
  2. for-each loop and a switch statement
    By Grot in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 4th, 2013, 01:02 PM
  3. How do I loop this if statement?
    By dunnage888 in forum Loops & Control Statements
    Replies: 5
    Last Post: February 10th, 2012, 11:16 AM
  4. Nested loop if statement help
    By CSUTD in forum Loops & Control Statements
    Replies: 7
    Last Post: November 8th, 2011, 01:05 PM
  5. How do I loop a switch Statement?
    By Arkeshen in forum Java Theory & Questions
    Replies: 7
    Last Post: July 19th, 2011, 06:25 AM