Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Brand-new to Java please help with project!

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    4
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Brand-new to Java please help with project!

    I am working on a project for my intro class and have hit a wall. This is my first time doing this sort of thing so please be gentle

    It goes as follows:

    For this project, you will create a Java application that accepts a student’s class grades from the keyboard; calculates the average grade as a percentage for each grading category; and then calculates the overall grade as both a percentage and a letter grade. The program then creates a grade report on the console showing both detail and aggregate information.

    The program prompts the user for the student’s name and stores that information in memory.
    The application inputs scores from the user in four grading categories--quizzes, in-class assignments, homework assignments and attendance--and stores that information in memory. You may choose to use objects of a class you create to store the score information.
    The application may prompt the user for this information using the console or a message dialog box.
    The prompt to the user for each score will indicate both the category of the score and a unique identifier for the score, e.g. “Quiz 3” or “Attendance 9/29/2018.”
    The program displays a report on the console with an appropriate title showing the student’s name that was entered by the user and the details of each grade entered:
    grade category (quiz, in-class assignment, homework or attendance)
    score name (e.g. “Quiz 3” or “Homework 4”)
    points earned
    points possible
    The program displays on the report the average score, as a percentage, for each grading category and labels each clearly. Where you choose to display all the elements on the report is up to you. Just remember readability is important.
    Attendance is worth 1 point per day and counts for 20% of the total grade. Create six attendance scores from user input.
    Quizzes are 10 points each and count for 20% of the total grade. Create six quiz scores from user input.
    In-class assignments are 10 points each and count for 20% of the total grade. Create six in-class assignment scores from user input.
    Homework assignments are 20 points each and count for 40% of the total grade. Create six homework assignment scores from user input.
    The report displays an overall grade as both a percentage and as a letter grade. Use the following ranges to determine the letter grade.
    A

    90 through 100

    B

    80 to < 90

    C

    70 to < 80

    D

    60 to < 70

    F

    < 60


    So... (for what it's worth) here is what I have come up with so far...

     
    package studentgrades;
    //*import packages*//
     
    import java.util.*;
     
    //declare class
     
    public class StudentGrades
     
    {
     
    //Declare scanner object
     
    public static Scanner sc = new Scanner(System.in);
     
    //Declare global variables
     
    public static int attendanceScore = 6;
     
    public static int quizScore = 60;
     
    public static int inclassScore = 60;
     
    public static int homeworkScore = 120;
     
    public static int inputStudent = 0;
     
    //main method
     
    public static void main (String[] args)
     
    {
     
         //call the method
     
         //Outputs introduction
     
    System.out.println("This program calculates the Student's six day attendance record,");
    System.out.println("six different quiz scores, along with scores from six in-class");
    System.out.println("assignments and six homework assignments.");
     
    System.out.println("");
     
    System.out.println("The Student's final grade will be displayed");
    System.out.println("as both a percentage and a letter grade.");
     
     
         System.out.println();
     
    System.out.print("Input weights of each category");
         System.out.println();
    //weight of each category    
     
    System.out.print("What is the Weight of Attendance? ");
        int attendanceWeight= sc.nextInt();
     
    System.out.print("What is the Weight of Quizes? ");
        int quizWeight = sc.nextInt();
     
    System.out.print("What is the Weight of In-Class Assignments? ");
        int inClassAssignmentWeight = sc.nextInt();
     
    System.out.print("What is the Weight of Homework? ");
        int homeworkWeight = sc.nextInt();
     
     
    System.out.println();
     
     
    System.out.print("Please Enter Student's Name: ");
        int inputStudent = sc.nextInt();
     
    //Enter grades for each attendance point
     
    System.out.print("Grade of attendance 10/8/2018? ");
    int attendance1 = sc.nextInt();
    System.out.print("Grade of attendance 10/9/2018? ");
    int attendance2 = sc.nextInt();
    System.out.print("Grade of attendance 10/10/2018? ");
    int attendance3 = sc.nextInt();
    System.out.print("Grade of attendance 10/11/2018? ");
    int attendance4 = sc.nextInt();
    System.out.print("Grade of attendance 10/12/2018? ");
    int attendance5 = sc.nextInt();
    System.out.print("Grade of attendance 10/15/2018? ");
    int attendance6 = sc.nextInt();
     
    //Enter grades for each quiz score
     
    System.out.print("Grade of quiz 1? ");
    int quiz1grade = sc.nextInt();
    System.out.print("Grade of quiz 2? ");
    int quiz2grade = sc.nextInt();
    System.out.print("Grade of quiz 3? ");
    int quiz3grade = sc.nextInt();
    System.out.print("Grade of quiz 4? ");
    int quiz4grade = sc.nextInt();
    System.out.print("Grade of quiz 5? ");
    int quiz5grade = sc.nextInt();
    System.out.print("Grade of quiz 6? ");
    int quiz6grade = sc.nextInt();
     
    //Enter grades for each in-class assignment score
     
    System.out.print("Grade of in-class assignment 1? ");
    int inclassAssignment1grade = sc.nextInt();
    System.out.print("Grade of in-class assignment 2? ");
    int inclassAssignment2grade = sc.nextInt();
    System.out.print("Grade of in-class assignment 3? ");
    int inclassAssignment3grade = sc.nextInt();
    System.out.print("Grade of in-class assignment 4? ");
    int inclassAssignment4grade = sc.nextInt();
    System.out.print("Grade of in-class assignment 5? ");
    int inclassAssignment5grade = sc.nextInt();
    System.out.print("Grade of in-class assignment 6? ");
    int inclassAssignment6grade = sc.nextInt();
     
    //Enter grades for each homework assignment score
     
    System.out.print("Grade of homework assignment 1? ");
    int homeworkAssingment1grade = sc.nextInt();
    System.out.print("Grade of homework assignment 2? ");
    int homeworkAssingment2grade = sc.nextInt();
    System.out.print("Grade of homework assignment 3? ");
    int homeworkAssingment3grade = sc.nextInt();
    System.out.print("Grade of homework assignment 4? ");
    int homeworkAssingment4grade = sc.nextInt();
    System.out.print("Grade of homework assignment 5? ");
    int homeworkAssingment5grade = sc.nextInt();
    System.out.print("Grade of homework assignment 6? ");
    int homeworkAssingment6grade = sc.nextInt();
     
         System.out.println();  
     
     
    System.out.println("Each grade as a Percentage for" + inputStudent + "per category are recorded as follows");
     
     
    //Percentage of total in Attendance
     
    System.out.print("Attendance = " + (((attendanceWeight/100)*((attendance1 + attendance2 + attendance3 + attendance4 + attendance5 + attendance6)/(attendanceScore))+ "%" )));
     
         System.out.println();  
     
    //Percentage of total in Quizes
     
    System.out.print("Quizes = " + (((quizWeight/100) * (quiz1grade + quiz2grade + quiz3grade + quiz4grade + quiz5grade + quiz6grade)/(quizScore)+ "%" )));
     
         System.out.println();
     
    //Percentage of total in In-class Assignments
     
    System.out.print("In-Class Assignments " + (((inClassAssignmentWeight/100) * (inclassAssignment1grade + inclassAssignment2grade + inclassAssignment3grade
                                            +inclassAssignment4grade + inclassAssignment5grade + inclassAssignment6grade)/(inclassScore)+ "%" )));
         System.out.println();  
     
    //Percentage of total in In-class Assignments
     
    System.out.print("Homework Assignments " + (((homeworkWeight/100) * (homeworkAssingment1grade + homeworkAssingment2grade + homeworkAssingment3grade
                                            +homeworkAssingment4grade + homeworkAssingment5grade + homeworkAssingment6grade)/(homeworkScore)+ "&" )));
     
         System.out.println();  
     
         System.out.println();
     
    }
     
    }

    Any help would be greatly appreciated!

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Brand-new to Java please help with project!

    What problems are you having with the project?
    Do you have any specific java programming questions?

    Note: The source code's indentations need work. Too many statements start in the first column. Proper formatting makes the code easier to read.
    Also too many variables are static.
    And there is too much code in the main method. Divide the code up into logical sections and put each section in a separate method.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Oct 2018
    Posts
    4
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Brand-new to Java please help with project!

    I have, through trial and error, gotten the code to run, now I am just fixing formatting issues. Please stay tuned as I am sure I will have more problems. It was pasted from a .txt file which makes the formatting look worse than it really is in the ide.

  4. #4
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: Brand-new to Java please help with project!

    Thought you should know that the following expression,


    (attendanceWeight/100)


    will evaluate to 0 (zero) for any values for attendanceWeight from 1 to 99. Integer division drops
    fractions. Same is true for other similar expressions.

    Regards,
    Jim

  5. #5
    Junior Member
    Join Date
    Oct 2018
    Posts
    4
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Brand-new to Java please help with project!

    Ok, here is the nightmare I have come up with. The last step it seems, would be to then convert the student's percentage grade into a letter grade. I have no idea where to start. Can someone steer me in the right direction?

    Thank you


    package studentgrades;
    //*import packages*//
     
    import java.util.*;
     
    //class
     
    public class StudentGrades
     
    {
     
    //Declare scanner object
     
    public static Scanner sc = new Scanner(System.in);
     
    //Declare global variables
     
    public static int attendanceScore = 6;
     
    public static int quizScore = 60;
     
    public static int inclassScore = 60;
     
    public static int homeworkScore = 120;
     
    public static int inputstudentfirst = 0;
     
    public static int inputstudentlast = 0;
     
    public static int getgrade = 0;
     
    public static int prompscore = 0;
     
     
    //main method
     
    public static void main (String[] args)
     
    {
    //Introduction
     
    System.out.println("This program calculates the Student's six day attendance record,");
        System.out.println("six different quiz scores, along with scores from six in-class");
        System.out.println("assignments and six homework assignments.");
        System.out.println("");
        System.out.println("The Student's final grade will be displayed");
        System.out.println("as both a percentage and a letter grade.");
        System.out.println();
     
    //weight of each category   
     
    System.out.print("Weight of each category");
        System.out.println();
        System.out.print("Attendance: ");
        int attendanceWeight= sc.nextInt();
        System.out.print("Quizes: ");
        int quizWeight = sc.nextInt();
        System.out.print("In-Class Assignments: ");
        int inclassAssignmentWeight = sc.nextInt();
        System.out.print("Homework: ");
        int homeworkWeight = sc.nextInt();
        System.out.println();
     
    //Student's Name Lines
     
    System.out.print("Enter Student's First and Last Name: ");
        sc.nextLine();
        System.out.print(" ");
        String inputStudentName = sc.nextLine();
        System.out.println();
        System.out.print("");
        System.out.print("Enter Points Earned For Each Assignment: ");
        System.out.println();
        System.out.println();
    //Enter grades for each attendance point
     
    System.out.print("Category: Attendance");
        System.out.println();
        System.out.print("Max Points For This Category Per Assignment: 1 Point(s)");
        System.out.println();
        System.out.println();
        System.out.print("10/8/2018: ");
        int attendance1 = sc.nextInt();
        System.out.print("10/9/2018: ");
        int attendance2 = sc.nextInt();
        System.out.print("10/10/2018: ");
        int attendance3 = sc.nextInt();
        System.out.print("10/11/2018: ");
        int attendance4 = sc.nextInt();
        System.out.print("10/12/2018: ");
        int attendance5 = sc.nextInt();
        System.out.print("10/15/2018: ");
        int attendance6 = sc.nextInt();
        System.out.println();
     
    //Enter grades for each quiz score
     
    System.out.print("Category: Quizes ");
        System.out.println();
        System.out.print("Max Points For This Category Per Assignment: 10 Point(s)");    
        System.out.println();
        System.out.println();
        System.out.print("Quiz 1: ");
        int quiz1grade = sc.nextInt();
        System.out.print("Quiz 2: ");
        int quiz2grade = sc.nextInt();
        System.out.print("Quiz 3: ");
        int quiz3grade = sc.nextInt();
        System.out.print("Quiz 4: ");
        int quiz4grade = sc.nextInt();
        System.out.print("Quiz 5: ");
        int quiz5grade = sc.nextInt();
        System.out.print("Quiz 6: ");
        int quiz6grade = sc.nextInt();
        System.out.println();
     
    //Enter grades for each in-class assignment score
     
    System.out.print("Category: In-Class Assignments");
        System.out.println();
        System.out.print("Max Points For This Category Per Assignment: 10 Point(s)");    
        System.out.println();
        System.out.println();
        System.out.print("Assignment 1: ");
        int inclassAssignment1grade = sc.nextInt();
        System.out.print("Assignment 2: ");
        int inclassAssignment2grade = sc.nextInt();
        System.out.print("Assignment 3: ");
        int inclassAssignment3grade = sc.nextInt();
        System.out.print("Assignment 4: ");
        int inclassAssignment4grade = sc.nextInt();
        System.out.print("Assignment 5: ");
        int inclassAssignment5grade = sc.nextInt();
        System.out.print("Assignment 6: ");
        int inclassAssignment6grade = sc.nextInt();
        System.out.println();
     
    //Enter grades for each homework assignment score
     
    System.out.print("Category: Homework Assignments");
        System.out.println();
        System.out.print("Max Points For This Category Per Assignment: 20 Point(s)");    
        System.out.println();
        System.out.println();
        System.out.print("Assignment 1: ");
        int homeworkAssingment1grade = sc.nextInt();
        System.out.print("Assignment 2: ");
        int homeworkAssingment2grade = sc.nextInt();
        System.out.print("Assignment 3: ");
        int homeworkAssingment3grade = sc.nextInt();
        System.out.print("Assignment 4: ");
        int homeworkAssingment4grade = sc.nextInt();
        System.out.print("Assignment 5: ");
        int homeworkAssingment5grade = sc.nextInt();
        System.out.print("Assignment 6: ");
        int homeworkAssingment6grade = sc.nextInt();
        System.out.println();  
     
    //Text for Grades for Student
     
    System.out.println("Each grade as a Percentage for " + inputStudentName + 
        " " + " per category have been recorded as follows:");
        System.out.println();     
     
    //Percentage of total in Attendance
     
    float attendanceWeightMultiplier = (float) attendanceWeight; 
        float attendanceGrade = (float)(attendance1 + attendance2 
        + attendance3 + attendance4 + attendance5 + attendance6)/(attendanceScore);
        float attendance = attendanceWeightMultiplier * attendanceGrade;  
        System.out.print("Attendance   " + attendance + " / " + attendanceWeight);
        System.out.println();  
     
    //Percentage of total in Quizes
     
    float quizWeightMultiplier = (float) quizWeight;
        float quizGrade = (float) (quiz1grade + quiz2grade 
        + quiz3grade + quiz4grade + quiz5grade + quiz6grade)/(quizScore);
        float quiz = quizWeightMultiplier * quizGrade;  
        System.out.print("Quizes       " + quiz + " / " + quizWeight);
        System.out.println();
     
    //Percentage of total in In-class Assignments
     
    float inclassAssignmentMultiplier = (float) inclassAssignmentWeight;
        float inclassAssignmentGrade = (float) (inclassAssignment1grade + inclassAssignment2grade + inclassAssignment3grade
        +inclassAssignment4grade + inclassAssignment5grade + inclassAssignment6grade)/(inclassScore);
        float inclassAssignment = inclassAssignmentMultiplier * inclassAssignmentGrade;
        System.out.print("In-Class     " + inclassAssignment + " / " + inclassAssignmentWeight);
        System.out.println();
     
    //Percentage of total in In-class Assignments
     
    float homeworkAssignmentMultiplier = (float) homeworkWeight;
        float homeworkAssignmentGrade = (float) (homeworkAssingment1grade + homeworkAssingment2grade + homeworkAssingment3grade
        +homeworkAssingment4grade + homeworkAssingment5grade + homeworkAssingment6grade)/(homeworkScore);
        float homeworkAssignment = homeworkAssignmentMultiplier * homeworkAssignmentGrade;
        System.out.print("Homework     " + homeworkAssignment + " / " + homeworkWeight);
        System.out.println();
        System.out.print(("TOTAL POINTS EARNED: " 
     
                //ATTENDANCE GRADES
     
                +(attendance1 + attendance2 + attendance3 
                + attendance4 + attendance5 + attendance6
     
                //QUIZ GRADES        
     
                + quiz1grade + quiz2grade + quiz3grade
                + quiz4grade + quiz5grade + quiz6grade 
     
                //IN-CLASS ASSIGMENTS
     
                + inclassAssignment1grade + inclassAssignment2grade + inclassAssignment3grade
                + inclassAssignment4grade + inclassAssignment5grade + inclassAssignment6grade 
     
                //HOMEWORK ASSIGNMENTS
     
                + homeworkAssingment1grade + homeworkAssingment2grade + homeworkAssingment3grade 
                + homeworkAssingment4grade + homeworkAssingment5grade + homeworkAssingment6grade))
     
                //TOTAL POINTS AVAILABLE
     
                + " / " + (attendanceScore + quizScore + inclassScore + homeworkScore));
        System.out.println();
        System.out.println();
     
    //Computation for actual percentage
     
     System.out.print(inputStudentName + " has a " + (float)(
     
            //ATTENDANCE GRADES FOR ACTUAL COMPUTATION
                +(attendance1 + attendance2 + attendance3 
                + attendance4 + attendance5 + attendance6
     
            //QUIZ GRADES FOR ACTUAL COMPUTATION
                + quiz1grade + quiz2grade + quiz3grade
                + quiz4grade + quiz5grade + quiz6grade 
     
            //IN-CLASS ASSIGMENTS FOR ACTUAL COMPUTATION
                + inclassAssignment1grade + inclassAssignment2grade + inclassAssignment3grade
                + inclassAssignment4grade + inclassAssignment5grade + inclassAssignment6grade 
     
            //HOMEWORK ASSIGNMENTS FOR ACTUAL COMPUTATION        
                + homeworkAssingment1grade + homeworkAssingment2grade + homeworkAssingment3grade 
                + homeworkAssingment4grade + homeworkAssingment5grade + homeworkAssingment6grade))
     
            //TOTAL POINTS AVAILABLE FOR ACTUAL COMPUTATION
                / (attendanceScore + quizScore + inclassScore + homeworkScore)*100 + "%"+" in the class");
        System.out.println();
     
    }
    }

  6. #6
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: Brand-new to Java please help with project!

    Well, if the percentage is between to values, give them the appropriate grade. Use a logical "if" statement.


    Regards,
    Jim

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Brand-new to Java please help with project!

    See the instructions:
    Use the following ranges to determine the letter grade.
    A

    90 through 100

    B

    80 to < 90

    C

    70 to < 80

    D

    60 to < 70

    F

    < 60
    Note: The source code needs to have proper indentations. Each level of nested logic needs to be indented 3 or 4 columns from the previous indentation. There should never be one } in the same column below another }
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Help! I am brand new to Java and I need help!
    By Techstudent in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 21st, 2013, 02:04 PM
  2. Brand new to Java and programming
    By mwr76 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 26th, 2011, 08:41 PM
  3. [PROJECT] JWebby: A brand new webserver
    By Verficon in forum Java Networking
    Replies: 2
    Last Post: March 7th, 2011, 11:49 AM
  4. [SOLVED] Brand Spanking New to Java...
    By forte in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 18th, 2010, 06:41 AM