We help IT Professionals succeed at work.
Get Started

Simple Java Methods question (Edited)

Kevin Blakely
Last Modified: 2017-11-16

I'm new to coding (total novice) and i am having trouble with the following program. (see below and question attached)

How do I print out my assignGrade method??? I had to initialise it in Main manually. The rest of the program works fine?
package Lab8;
import java.util.Scanner;

public class ClassTest2Retry {

    static Scanner input = new Scanner(System.in);

    //method enterName()
    public static String enterName(){
        System.out.println("Enter name");
        return input.nextLine();
    //method enterMark()
    public static int enterMark(String value){
        return input.nextInt();
    //method calculateAverage()
    public static int calculateaverage(int solo, int prose, int poem){
        return ((solo + prose + poem) /3);
    // method assignGrade
    public static String assignGrade(int overall){
        if (overall <40){
            return "Fail";
        }else if (overall >40) {
            return "Pass";
                return "Distinction";
    //method output results
    public static void outputResults (String name, int solo, int prose, int poem, int average, String grade){
        System.out.println("Name\t\t\t\t Solo\t\t\t\t Prose\t\t\t\t Poem\t\t\t\t Avg\t\t\t\t Grade");
        System.out.println(name + "\t\t" + solo+ "\t\t\t\t\t"+ prose+"\t\t\t\t\t" + poem + "\t\t\t\t\t"+ average);

    public static void main(String[] args) {
        String nameMain, gradeMain;
        int soloMarkMain, proseMarkMain, poemMarkMain, averageMain, overallMain = 70;

        nameMain = enterName();
        soloMarkMain = enterMark("Enter Solo Mark");
        proseMarkMain = enterMark("Enter Prose Mark");
        poemMarkMain = enterMark("Enter Poem Mark");
        averageMain = calculateaverage(soloMarkMain, proseMarkMain,poemMarkMain);
        gradeMain = assignGrade(overallMain);
        outputResults(nameMain, soloMarkMain, proseMarkMain, poemMarkMain, averageMain, gradeMain);

    }//end main
}//end class
Watch Question
Distinguished Expert 2020
This problem has been solved!
Unlock 2 Answers and 2 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE