Question

Java - In NetBeans IDE: • Create a class called Student which stores: - the name...

Java - In NetBeans IDE:

• Create a class called Student which stores:

- the name of the student

- the grade of the student

• Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into the grade field.

• Calculate the average of all students’ grades.

• Open the output file, for writing, and print all the students’ names on one line and the average on the next line.

• Average should only have 1 digit after the decimal

• “Average” should be left justified in a field of 15 characters. The average # should be right justified in a field of 10 spaces

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;
public class student
{
String name;
int sub[];
double avg=0;
   public student()
   {
    Scanner sc=new Scanner(System.in);
    sub=new int[5];
    System.out.println("Enter the name student:");
    name=sc.nextLine();
    int i;

    for(i=0;i<5;i++)
    {
   System.out.println("Enter the marks of subject "+(i+1));
   sub[i]=sc.nextInt();
   avg+=sub[i];
     
   }
   avg/=5;
     
   }

   public void getGrade()
   {
   System.out.println("Result of"+name+":");
   for(int i=0;i<5;i++)
{
   System.out.println("Marks of "+i+1+":"+sub[i]);
   }
   System.out.println("Grade point average:"+avg/10);
      
   }
}


import java.util.Scanner;
public class TestStudent
{
   public static void main(String args[])
   {
   Scanner sc=new Scanner(System.in);
   System.out.println("Enter the number of student");
   int n=sc.nextInt();
   student stu[]=new student[n];
   for(int i=0;i<n;i++)
   {
   student st=new student();
   stu[i]=st;
      
   }
   String c="";
   while(true)
   {
   System.out.println("Enter the student index to know the detail");
   System.out.println("Type enter to exit");
   c=sc.next();
   if(c.equals("exit"))
   {
   break;
      
   }
   else
   {
   int num=Integer.parseInt(c);
   stu[num].getGrade();
}
}
}
}

Add a comment
Know the answer?
Add Answer to:
Java - In NetBeans IDE: • Create a class called Student which stores: - the name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a Student grading system. You should use a person base class (stores the name of...

    Create a Student grading system. You should use a person base class (stores the name of the student). Derive a student class from the person class. The student class stores the student ID. The student class should also store the students 3 exams (Test 1, Test 2, and Test 3) and calculate a final grade (assume the 3 tests count equally). Create an array of students for a class size of 15 students. You can use the keyboard to read...

  • Java - In NetBeans IDE: •Design an abstract class called BankAccount which stores the balance. –Implement...

    Java - In NetBeans IDE: •Design an abstract class called BankAccount which stores the balance. –Implement a constructor that takes the balance (float). –Provide abstract methods deposit(amount) and withdraw(amount) •Design a class called SavingsAccount which extends BankAccount. –Implement a constructor that takes the balance as input. –It should store a boolean flag active. If the balance at any point falls below $25, it sets the active flag to false. It should NOT allow the balance to fall below $0. –If...

  • Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student...

    Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student gradebook using a two-dimensional array. It should allow the user to enter the number of students and the number of assignments they wish to enter grades for. This input should be used in defining the two-dimensional array for your program. For example, if I say I want to enter grades for 4 students and 5 assignments, your program should define a 4 X 5...

  • Write a C program to compute average grades for a course. The course records are in...

    Write a C program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student’s first name, then one space, then the student’s last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • Write a program in Java using netbeans IDE that stores, retrieves, adds, and updates addresses as...

    Write a program in Java using netbeans IDE that stores, retrieves, adds, and updates addresses as shown in figure 17.20. Use a fixed length string for storing each attribute in the address. Use random access file for reading and writing an address. Assume that the size of name, street, city, state, and zip is 32, 32,20, 2, 5 chars, respectively.

  • Create a class called Student. This class will hold the first name, last name, and test...

    Create a class called Student. This class will hold the first name, last name, and test grades for a student. Use separate files to create the class (.h and .cpp) Private Variables Two strings for the first and last name A float pointer to hold the starting address for an array of grades An integer for the number of grades Constructor This is to be a default constructor It takes as input the first and last name, and the number...

  • using C# Write a program which calculates student grades for multiple assignments as well as the...

    using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...

  • java Part 1 Create a NetBeans project that asks for a file name. The file should...

    java Part 1 Create a NetBeans project that asks for a file name. The file should contain an unknown quantity of double numeric values with each number on its own line. There should be no empty lines. Open the file and read the numbers. Print the sum, average, and the count of the numbers. Be sure to label the outputs very clearly. Read the file values as Strings and use Double.parseDouble() to convert them. Part 2 Create a NetBeans project...

  • Java netbeans, points out of 10 Exercise#3 Create a class CourseGrades that consists of two data...

    Java netbeans, points out of 10 Exercise#3 Create a class CourseGrades that consists of two data fields, student_id and grade. The class has set and get methods for each data variable. Then, write a Java program that reads students ids and corresponding grades into an array of type CourseGrades and print the average grade for the class. Your program should have two methods in addition to main(), one method for reading the students ids and grades and another method for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT