Session 6

Source Code

import java.util.*;

public class Session6 {
    public static void main(String[] main) {
        System.out.println("Session 6");
        // example1 method call
        
        
        // example2 method call
        
        
    }
    // example1 method definition
    
    
    // example2 method definition
    
    
}

NumberHelper.java

public class NumberHelper {

    /**
     * Doubles the given number.
     * Formula: result = num * 2
     *
     * @param num the number to double
     * @return the result of num multiplied by 2
     */



    /**
     * Finds the average of two numbers.
     * Formula: average = (a + b) / 2.0
     *
     * @param a the first number
     * @param b the second number
     * @return the average of a and b as a double
     */

    public static void main(String[] args) {
        System.out.println("Class Methods Example");
        // call Class methods
        
    }
}

S6Problem1.java

import java.util.*;

public class S6Problem1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Problem 1");
        System.out.print("Enter the length of the rectangular solid: ");

        System.out.print("Enter the width of the rectangular solid: ");

        System.out.print("Enter the height of the rectangular solid: ");

        // call Rectangular Solid method
        System.out.println("Volume of the Rectangular Solid: ");

    }

    // define Volume of a Rectangular Solid method

}

S6Problem2.java

import java.util.*;

public class S6Problem2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Problem 2");
        System.out.print("Enter the semi-axis a of the ellipsoid: ");

        System.out.print("Enter the semi-axis b of the ellipsoid: ");

        System.out.print("Enter the semi-axis c of the ellipsoid: ");

        // call Ellipsoid method
        System.out.println("Volume of the Ellipsoid: ");



    }

    // define Volume of a Ellipsoid method

}

S6Problem3.java

import java.util.*;

public class S6Problem3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Problem 3");
        System.out.print("Enter the radius of the circular base of the cylinder: ");

        System.out.print("Enter the height of the cylinder: ");

        // call Cylinder method
        System.out.println("Volume of the Cylinder: ");


    }

    // define Volume of a Cylinder method

}

S6Problem4.java

import java.util.*;

public class S6Problem4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Problem 4");
        System.out.print("Enter the radius of the cone's base: ");

        System.out.print("Enter the height of the cone: ");

        // call Cone method
        System.out.println("Volume of the Cone: ");


    }

    // define Volume of a Cone method

}

S6Problem5.java

import java.util.*;

public class S6Problem5 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Problem 5");
        System.out.print("Enter the length of the rectangular pyramid's base: ");

        System.out.print("Enter the width of the rectangular pyramid's base: ");

        System.out.print("Enter the height of the rectangular pyramid: ");

        // call Rectangular Pyramid method
        System.out.println("Volume of the Rectangular Pyramid: ");


    }

    // define Volume of a Rectangular Pyramid method

}

AreaCalculator.java

/**
 * The AreaCalculator class provides static methods
 * to calculate the area of various 2D shapes.
 * 
 * All methods use standard geometric formulas and return
 * a double value representing the calculated area.
 * 
 * Author: Your Name
 * Date: 2025-10-17
 */
public class AreaCalculator {

    /**
     * Calculates the area of a rectangle.
     * @param l the length of the rectangle
     * @param w the width of the rectangle
     * @return the area of the rectangle
     */


    /**
     * Calculates the area of a triangle.
     * @param b the base of the triangle
     * @param h the height of the triangle
     * @return the area of the triangle
     */


    /**
     * Calculates the area of a circle.
     * @param r the radius of the circle
     * @return the area of the circle
     */


    /**
     * Calculates the area of a trapezoid.
     * @param b1 the length of the first base
     * @param b2 the length of the second base
     * @param h the height of the trapezoid
     * @return the area of the trapezoid
     */


    /**
     * Calculates the area of a parallelogram.
     * @param b the base of the parallelogram
     * @param h the height of the parallelogram
     * @return the area of the parallelogram
     */
 

    /**
     * Calculates the area of a square.
     * @param s the length of one side
     * @return the area of the square
     */


    /**
     * Calculates the area of a rhombus.
     * @param d1 the length of the first diagonal
     * @param d2 the length of the second diagonal
     * @return the area of the rhombus
     */


    /**
     * Calculates the area of an ellipse.
     * @param a the semi-major axis
     * @param b the semi-minor axis
     * @return the area of the ellipse
     */


    public static void main(String[] args) {
        System.out.println("Area Calculator");
        // System.out.println("Rectangle: " + AreaCalculator.rectangle(5, 3));
        // System.out.println("Triangle: " + AreaCalculator.triangle(6, 4));
        // System.out.println("Circle: " + AreaCalculator.circle(2));
        // System.out.println("Trapezoid: " + AreaCalculator.trapezoid(3, 5, 4));
        // System.out.println("Parallelogram: " + AreaCalculator.parallelogram(8, 3));
        // System.out.println("Square: " + AreaCalculator.square(4));
        // System.out.println("Rhombus: " + AreaCalculator.rhombus(6, 8));
        // System.out.println("Ellipse: " + AreaCalculator.ellipse(5, 3));

        
    }
}

GradeCalculator.java

/**
 * The GradeCalculator class calculates a student's final course grade
 * by combining weighted category scores (homework, quizzes, and exam) 
 * and adding extra credit
 */
public class GradeCalculator {

    /**
     * The main method displays a formatted grade report.
     */
    public static void main(String[] args) {
        System.out.println("===== GRADE CALCULATOR =====\n");
        System.out.println("AP Computer Science A - Term Grade\n");
        
        // Ask the user for their overall assignment grade
        
        // Ask the user for their overall quiz grade
        
        // Ask the user for their end of term grade
        

        // Display weighted scores
        System.out.println("Assignments 60%): ");
        System.out.println("Quizzes (30%): ");
        System.out.println("End of Term Exam (10%): ");

        // Calculate total grade

        System.out.println("\nBase Grade: ");

        // Ask the number of points to add for extra credit

        System.out.println("After Extra Credit: ");
    }

    /**
     * Calculates the weighted score for a given category.
     *
     * @param score  the percentage score for the category (0–100)
     * @param weight the weight of the category as a decimal (e.g., 0.20 for 20%)
     * @return the weighted score (score × weight)
     */
 

    /**
     * Calculates the total grade by summing three category scores.
     *
     * @param a the first category score
     * @param b the second category score
     * @param c the third category score
     * @return the total of all four category scores
     */

    /**
     * Adds extra credit points to a total grade.
     *
     * @param total the current total grade before extra credit
     * @param extra the amount of extra credit to add
     * @return the final grade after adding extra credit
     */

}

Last updated

Was this helpful?