Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6172237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:21:28+00:00 2026-05-23T23:21:28+00:00

I try to make total scores and weighted scores into return value and the

  • 0

I try to make total scores and weighted scores into return value and the parameters are passed from the scanner console, and the return values are called from the static void method.

import java.util.*;

public class Grades {
    public static void main (String[] args) {

        intro();

        Scanner console = new Scanner(System.in);

        int totalScoreMain = totalScore(score, curveNumber);
        double weightedScoreMain = weightedScore(weight, score, curveNumber);
        double weightedScore2Main = weightedScore2(weight2, sections, sumScore);

        for(int i = 1; i <= 2; exam++); {
            System.out.println("Exam i");
            exam();
        }
        homework();
}

public static void intro () {

        System.out.println("This program reads exam/homework scores");
        System.out.println("and reports your overall course grade.");
        System.out.println();
    }


public static void exam () {

        System.out.print("What is its weight (0-100)?");
        double weight = console.nextInt();
        System.out.print("Score earned?");
        int score = console.nextInt();
        System.out.print("Was there a curve (1=yes, 2=no)?");
        int curve = console.nextInt();
            if (curve == 1) {
                System.out.print("How much was the curve?");
                int curveNumber = console.nextInt();    
            } else if (curve == 2) {
                int curveNumber = 0;
            }

        totalScore(score, curveNumber);
        weightedscore(weight, score, curveNumber);

        System.out.println("Total points = " + totalScoreMain + "/" + "100");
        System.out.println("Weighted score = " + weightedScoreMain + "/" + weight);
    }

public static int totalScore (int score, int curveNumber) {

        int totalScore = Math.min(score + curveNumber, 100);
        return totalScore;
    }

public static double weightedScore (int weight, int score, int curveNumber) {

        double weightedScore = (score + curveNumber) * weight/100;
        return weightedScore;
    }

public static void homework () {

        System.out.print("What is its weight (0-100)?");
            int weight2 = console.nextInt();
        System.out.print("Number of assignments?");
            int number = console.nextInt();
            int sumScore = 0;
            int sumMax = 0;

        for(int i = 1; i <= number; i++) {
            System.out.println("Assignment " + i + "score and max?");
                int aScore = console.nextInt();
                int aScoreMax = console.nextInt();

                sumScore = sumScore + aScore;
                sumMax = sumMax + aScoreMax; }

            System.out.print("How many sections attended?");
                int section = console.nextInt();
                int sections = Math.min(3 * section, 20);
            System.out.println("Section points = " + sections);

            weightedScore2(weight2, sections, sumScore);

                System.out.println("Total points = " + (sections + sumScore) + "/" + sumMax);
                System.out.println("Weighted score = " + weightedScore2 + "/" + weight2);
        }


public static double weightedScore2(int weight2, int sections, int sumScore) {

            int weightedScore2 = weight2/100 * (sections + sumScore);
            return weightedScore2;
        }
    }       

Can someone help me to understand what I’m doing incorrectly? I don’t understand why what I’ve pasted is not working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:21:28+00:00Added an answer on May 23, 2026 at 11:21 pm

    You seem not to have understood the scope of variables, yet. The way your program is designed, the main method creates a Scanner object called console but has a reference that is only available inside this method. In order to use it in exam(), you would have to pass the reference in some way or make it some kind of member (or wahtever, don’t try to fix things there, there’s much more broken as it is). However, you most probably just want to create the object in exam(), because it is only used in that method.

    It’s the same with weight, score, etc. You attempt to use them in the main method, but at that point, they are simply not there!

    You should try to start withan almost empty main method, add line by line and always compile and try to run it and see if it works like you want it to. If it doesn’t, ask for help on that particular problem.

    In the code you posted, there are so many errors that it is almost impossible to find a good point to start with giving advice on what to do different.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Try to add value from checkboxes and item list to make a price calculator.
I try to make a apps that need barcode scanner, i already can get
I'm using Python 2.5 and trying to make a variable called total and adding
Im try make a slider and load data dynamically from a php file, im
I try to make function to check if table exists and to get total
I am try to make the myFunction give me a sum of the values
I want to make this into a function: var meanPoints = d3.mean(data, function(d) {return
I try to make my ListBox connected to ObservaleCollection be more efficient so for
I try to make an ActiveX by C# with COM-visible. It is a Windows
I try to make an imageview clickable. Actually it is clickable, so that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.