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?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
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 Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Threads in linked list
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education