Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i keep getting this message please help Error: Could not find or load main class main Caused by: java.lang.ClassNotFoundException: main import java.io.File; import java.io.FileNotFoundException; import

i keep getting this message please help

Error: Could not find or load main class main

Caused by: java.lang.ClassNotFoundException: main

import java.io.File;

import java.io.FileNotFoundException;

import java.io.PrintWriter;

import java.util.Scanner;

public class HW5

{

public void main (String[]args) throws FileNotFoundException

{

// change the name and path of the files accordingly

Scanner sc = new Scanner (new File ("testCase.txt"));

PrintWriter myout = new PrintWriter (new File ("Output.txt"));

//Variable declaration

int counter = 0, validCounter = 0, invalidCounter = 0;

int score1, score2, score3;

while (sc.hasNext ())

{ //looping file content

counter++;

String[] str = sc.nextLine ().split (","); //reading file and converting it to array

score1 = Integer.parseInt (str[0]);

score2 = Integer.parseInt (str[1]);

score3 = Integer.parseInt (str[2]);

//using the described methods

if (validGroup (score1, score2, score3, myout))

{

myout.println ("The group is valid");

validCounter++;

onegamescore (score1, myout);

onegamescore (score2, myout);

onegamescore (score3, myout);

myout.println ("Average score of the group is " +

avg3scores (score1, score2, score3));

}

else

invalidCounter++;

myout.println ();

myout.println ();

myout.println ();

}

sc.close ();

myout.println ("Total Group Counter: " + counter);

myout.println ("Total Valid Group Counter: " + validCounter);

myout.println ("Total Invalid Group Counter: " + invalidCounter);

myout.flush ();

myout.close ();

}

//checking for valid group

public static boolean validGroup (int score1, int score2, int score3,

PrintWriter myout)

{

boolean check = true;

int[] ar = { score1, score2, score3 }; //using array for storing score

for (int i = 0; i < ar.length; i++)

{ //looping the process

if (ar[i] < 0 || ar[i] > 300)

{

myout.println ("This group is invalid");

check = false;

if (ar[i] < 0)

myout.println (ar[i] + " is negeative");

else

myout.println (ar[i] + " is over 300");

}

}

return check;

}

//getting player rating

public static void onegamescore (int score, PrintWriter myout)

{

String rating = "";

if (score >= 250 && score <= 300)

rating = "professional game";

else if (score >= 200 && score <= 249)

rating = "excellent game";

else if (score >= 140 && score <= 199)

rating = "very good game";

else if (score >= 100 && score <= 139)

rating = "good game";

else if (score >= 50 && score <= 99)

rating = "poor game";

else

rating = "horrible game";

myout.println (score + " is a " + rating);

}

//finding average of the scores

public static int avg3scores (int score1, int score2, int score3)

{

return (score1 + score2 + score3) / 3;

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions