Beginner Java4: Enter student information (name and score only) on the keyboard and output it.

Source: Internet
Author: User

Beginner Java4: Enter student information (name and score only) on the keyboard and output it.


// Enter the student information (name and score only) on the keyboard and output it. Public class StuInformation {// StuScore may be more appropriate for naming String name; double score;} import java. util. contents;

public class TextStuInformation {
Public static void main (String [] args ){
Pipeline SC = new pipeline (System. in );
Int I = 0, j = 0;
// Information Input
System. out. print ("Enter the number of students you want to enter :");
Int num = SC. nextInt ();
StuInformation Stu [] = new StuInformation [num];
For (I = 0; I <Stu. length; I ++ ){
Stu [I] = new StuInformation ();
System. out. print ("Enter the" + (I + 1) + "Student name :");
Stu [I]. name = SC. next ();
System. out. print ("Enter the" + (I + 1) + "Student Score :");
Stu [I]. score = SC. nextDouble ();
}
// Information output
System. out. println ("\ t name \ t score ");
For (StuInformation stuInformation: Stu ){
System. out. println ("\ t" + stuInformation. name + "\ t" + stuInformation. score );
}
Double max = 0, min = 0;
Int cont = 0;
// Judge the highest score
For (I = 0; I <Stu. length; I ++ ){
If (max <Stu [I]. score ){
Max = Stu [I]. score;

Cont = I; // name of the student whose highest score is recorded

}
}
System. out. println ("Maximum score:" + Stu [cont]. name + "," + max );
// Determine the score
Min = Stu [0]. score;
For (j = 0; j <Stu. length; j ++ ){
If (min> = Stu [j]. score ){
Min = Stu [j]. score;
Cont = j; // name of the student whose lowest score is recorded
}
}
System. out. println ("min:" + Stu [cont]. name + "," + min );
SC. close ();
}
}
Result preview:

    

A_zhi
2016.08.18.22.00

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.