Question

When I try to run the following Java code on netbeans IDE, it says "erroneous tree type:scanner" and doesn't work. How to fix?

 

import java.util.*;
import java.text.*;
import java.util.Date;
class coursework{
String name,fgrade;
float ass1;
float ass2;
float prac;
float finalm;
double overall;
coursework(String name,float ass1,float ass2,float prac, float finalm)
{
this.name=name;
this.ass1=ass1;
this.ass2=ass2;
this.prac=prac;
this.finalm=finalm;
this.overall = 0.25*ass1+0.25*ass2+0.2*prac+0.3*finalm;
this.fgrade=finalgrade(this.overall);
}
String finalgrade(double m)
{
String g;
if(m>=80)
{
g="HD";
}
else if((m>=70)&&(m<80))
{
g="D";
}
else if((m>=60)&&(m<70)){
g="C";
}
else if((m>=50)&&(m>60))
{
g="P";
}else{
g="N";
}
return g;
}}

class researchstudent{
String name,fgrade;
float proposal;
float oral;
float thesis;
double overall;
researchstudent(String name,float proposal,float oral,float thesis)
{
this.name=name;
this.proposal=proposal;
this.oral=oral;
this.thesis=thesis;
this.overall = 0.3*proposal+0.1*oral+0.6*thesis;
this.fgrade=finalgrade(this.overall);
}
String finalgrade(double m)
{
String g;
if(m>=80)
{
g="HD";
}
else if((m>=70)&&(m<80))
{
g="D";
}
else if((m>=60)&&(m<70)){
g="C";
}
else if((m>=50)&&(m>60))
{
g="P";
}else{
g="N";
}
return g;
}
}
class Main{


public static void main(String[] args) {
int n,i,c,k=0,l=0;
String na;
float m1,m2,m3,m4,m5;
coursework w[] = new coursework[20];
researchstudent r[] = new researchstudent[20];

Scanner s= new Scanner(System.in);
System.out.println("Enter the number of students:\n");
n=s.nextInt();
for(i=0;i<n;i++)
{
System.out.println("Enter \n1.course work\n2.research student:\n");
c=s.nextInt();
if(c==1)
{
System.out.println("Enter the name\n");
na=s.next();
System.out.println("Enter the mark for assignment 1\n");
m1=s.nextInt();
System.out.println("Enter the mark for assignment 2\n");
m2=s.nextInt();
System.out.println("Enter the mark for practical\n");
m3=s.nextInt();
System.out.println("Enter the mark for final exam\n");
m4=s.nextInt();
w[k]=new coursework(na,m1,m2,m3,m4);
k++;
}
if(c==2)
{
System.out.println("Enter the name\n");
na=s.next();
System.out.println("Enter the mark proposal\n");
m1=s.nextInt();
System.out.println("Enter the mark for oral\n");
m2=s.nextInt();
System.out.println("Enter the mark for thesis\n");
m3=s.nextInt();
r[l]=new researchstudent(na,m1,m2,m3);
l++;
}
}
System.out.println("Results:\n");
if(k!=0)
{
for(int j=0;j<l;j++)
{
System.out.println("Name:"+ w[j].name+ " Grade : "+ w[j].fgrade);

}
}
if(l!=0)
{
for(int j=0;j<l;j++)
{
System.out.println("Name:"+ r[j].name+ " Grade : "+ r[j].fgrade);

}
}
}

}

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: A memory unit deploys a capacity to seek results based on a possible fifiltered match criteria (usin...

A: Memory unit is a segment of a computer framework to store information and data. It is a work territo...

Q: 6. Write a python program to sum the prime numbers existing in an array. For instance, if A = [4, 7,...

A: PROGRAM STRUCTURE: Initialize the required variables for the program. Take the number of elements f...

Q: What is BUS ? its characteristics and example, how many types of BUS?

A: A bus is a common pathway through which information and data flow from a computer component to anoth...

Q: write a c program to find out year in which mr kavi was born from the following information  kavi is...

A: Given,          Kavi is m years younger than his mother           Kavi's brother is born in the year...

Q: C++ Write a recursive function ‘bool palindrome(string s)’ that returns true if s is a palindrome an...

A: The code is written below- #include &lt;string&gt;#include &lt;iostream&gt;using namespace std;bool ...

Q: Write a python program to multiply the elements of two arrays in reverse order and then sum them up....

A: Hey, since there are multiple questions posted, we will answer first question. If you want any speci...

Q: exampleOne This program reads data from a physical file, create a reference to the file, perform a c...

A: Import the required library files. A file is created and kept in root directory which is the same as...

Q: Find 3 coding errors in the following method and correct them.    public void theTestMethod(int pass...

A: The method returns theNumber which is of integer type, so the method return type should int not void...

Q: Scenario Three: Smart Milk Jug A smart milk jug detects the pH level and remaining quantity of the...

A: The, answer has given below:

Q: applications of computer

A: Actually, computer is a electronic device. Which takes input and gives output. The, answer has given...

Q: C++ CODE

A: Approach Here, we are asked to replace if else-if with a switch statement. We will use the switch wi...

Q: Trace the following codes and upload the text file with your tracing. Devc++ version 5.11

A: Requirements: Trace the given code and upload the text file with your tracing. Program approach: In...

Q: Many large organizations have had their database system hacked and customer data stolen. How should ...

A: The, answer has given below:

Q: Evaluate situations in which you have seen people react to program and app problems on their compute...

A: The, answer has given below:

Q: Write C++ program to calculate percentage of students marks such as: First Receive Student Marks of...

A: Here, first you need to declare array for marks and one variable for number of subject i.e here "n"....

Q: Revise BST using a Comparatorfor comparing objects. Define the new class as BST&lt;E&gt; with twocon...

A: public static &lt;E&gt;BST&lt;E&gt; create (Comparator&lt;? super E&gt; comparator){ return new  Com...

Q: One of the following is not a type of conversion method during the implementation process:   ...

A: Under this strategy, consumers continue to function in the previous format in a personalized way, an...

Q: Tomorrow is the event of 23 March because of Pakistan day. You are wanting to go to see Parade in Is...

A: PROGRAM STRUCTURE: Include the required header files. Start the definition of the main function. De...

Q: Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1;...

A: Define .data segment with 3 sub segments chConstant, ch1 and ch2, each putting the value to 0 Define...

Q: In C++ Write a program that prints the count of all prime numbers between A and B (inclusive), where...

A: Approach Here, to print the count of all prime numbers between A and B inclusive, follow the below s...

Q: /*random number guessing game with while loopscreate a program (or adapt the guessing game program t...

A: Define header file &lt;iostream&gt; which is used for basic i/o operations in the file Define main m...

Q: 1. Create a prepared statement to display all employees' names in the department? (Dno) . 2. Define ...

A: The answer has given

Q: please help

A: eye function in Matlab program: The eye function is an in-built Matlab function and it is used to ge...

Q: In the context of EER data modeling, one can represent entities using superclasses and subclasses. U...

A: Extended-ER (EER) data model: EER is recognized as the high-level data model that is capable of incl...

Q: As it relates to methods, what is the difference between passing primitive data types versus passing...

A: Click to see the answer

Q: A room has one door, two windows, and a built-in bookshelf and it needs to be painted. Suppose that ...

A: Assuming that all doors and windows and bookshelf are in rectangular shape   Python Code: doorl = in...

Q: Please answer all questions for the while loop: while loop x=9;  // loop variable   while (x&gt;0)  ...

A: The while is pre condition test loop where, the condition is tested and it enters the loop only if t...

Q: Create a program in Python that takes a user's inputted set of data points, x and y values, until th...

A: Define module scipy.interpolate which contains interpolation activities Define function extrapolate ...

Q: Suppose in an implementation of STACK supports an instruction REVERSE which reverses the order of th...

A: The, answer has given below;

Q: I'm not sure we're to start on this problem

A: Click to see the answer

Q: python

A: count()-- returns number of times a specified value/string occurs in a  string index()-- return the ...

Q: Make a table chair program using java language.

A: Below is the required code in java. Save the program file with name TableAndChairs.java to successfu...

Q: write an algorithm code it in Python Tuition Fees Increase In 2008, BC charged $115 per credit for ...

A: 1. Declare 3 variables- year, cost, inc 2. Initialize variable- year with 2008, variable- cost with ...

Q: python

A: s = "Spam and eggs" print(s[:6])   here slicing operator is used. so it'll only print 6 letters from...

Q: The files provided in the code editor to the right contain syntax and/or logic errors. In each case,...

A: The code has given