Need help with Java Assignments

I am just starting out in programming. If someone could help me with these assignments, it would be greatly appreciated.




"Write a Rectangle class.
This class represents Rectangles. Each Rectange has the X and Y coordinates of its center point (as doubles) and its width and height (as double values, too). No other values should be stored! This means no area, no perimeter!

The class should have the following constructors and methods:
1. a constructor that takes X, Y, width, and height as arguments;
2. a constructor that takes only width and height as arguments;
3. a default constructor;
4. a method setCenter that takes X and Y as arguments;
5. a method setWidth that takes a width value;
6. a method setHeight that takes a height value;
7. a method getX that returns the X coordinate;
8. a method getY that returns the Y coordinate;
9. a method getWidth that returns the width value;
10. a method getHeight that returns the height value;
11. a method getArea calculates the area of the rectangle and returns it;
12. a method getPerimeter it calculates the perimeter of the rectangle and returns it;
13. a method toString that creates a String that includes the X, Y center coordinates, width, and height, and returns the string. This method does not use System.out.println() itself. It returns a String value to the caller.


Write an application (RectangleTest.java) to test your Rectangle class.
Your Application should test all the constructors and methods."


"Write a program to read a list of exam scores (integers in the range 0 to 100) and to output the total number of grades and the number of grades in each letter-grade category (90 to 100 = A, 80 to 89 = B, 70 to 79 = C, 60 to 69 = D, and 0 to 59 = F). The end of the input is indicated by a negative score as a sentinel value. (The negative value is used only to end the loop, so do not use it in the calculations.) For example, if the input is
98
87
86
85
85
78
73
72
72
72
70
66
63
50
-1

The output would be
Total number of grades=14
Number of A

Comments

  • : I am just starting out in programming. If someone could help me with
    : these assignments, it would be greatly appreciated.
    :
    :
    :
    :
    : "Write a Rectangle class.
    : This class represents Rectangles. Each Rectange has the X and Y
    : coordinates of its center point (as doubles) and its width and
    : height (as double values, too). No other values should be stored!
    : This means no area, no perimeter!
    :
    : The class should have the following constructors and methods:
    : 1. a constructor that takes X, Y, width, and height as arguments;
    : 2. a constructor that takes only width and height as arguments;
    : 3. a default constructor;
    : 4. a method setCenter that takes X and Y as arguments;
    : 5. a method setWidth that takes a width value;
    : 6. a method setHeight that takes a height value;
    : 7. a method getX that returns the X coordinate;
    : 8. a method getY that returns the Y coordinate;
    : 9. a method getWidth that returns the width value;
    : 10. a method getHeight that returns the height value;
    : 11. a method getArea calculates the area of the rectangle and
    : returns it;
    : 12. a method getPerimeter it calculates the perimeter of the
    : rectangle and returns it;
    : 13. a method toString that creates a String that includes the X, Y
    : center coordinates, width, and height, and returns the string. This
    : method does not use System.out.println() itself. It returns a String
    : value to the caller.
    :
    :
    : Write an application (RectangleTest.java) to test your Rectangle
    : class.
    : Your Application should test all the constructors and methods."
    :
    :
    : "Write a program to read a list of exam scores (integers in the
    : range 0 to 100) and to output the total number of grades and the
    : number of grades in each letter-grade category (90 to 100 = A, 80 to
    : 89 = B, 70 to 79 = C, 60 to 69 = D, and 0 to 59 = F). The end of the
    : input is indicated by a negative score as a sentinel value. (The
    : negative value is used only to end the loop, so do not use it in the
    : calculations.) For example, if the input is
    : 98
    : 87
    : 86
    : 85
    : 85
    : 78
    : 73
    : 72
    : 72
    : 72
    : 70
    : 66
    : 63
    : 50
    : -1
    :
    : The output would be
    : Total number of grades=14
    : Number of A
  • Solution for assignment no. 2


    Main Class:
    import java.util.Scanner;

    public class ExamScoresTest {

    public static void main(String[] args) {
    ExamScores myScores = new ExamScores();
    myScores.calculateGrade();
    }

    }

    Other Class:

    import java.util.Scanner;

    public class ExamScores {
    public int[] inputScore = new int[100];
    int countA = 0;
    int countB = 0;
    int countC = 0;
    int countD = 0;
    int countF = 0;
    int totalGrade = 0;
    Scanner myScanner = new Scanner (System.in);

    void calculateGrade() {
    System.out.println("enter scores");
    int i = 0;
    while (inputScore[i] >= 0) {
    i++;
    inputScore[i] = myScanner.nextInt();
    }
    for (int j=1; j<=i-1; j++){
    if (inputScore[j] >= 90){
    countA++;
    }
    if (inputScore[j] < 90 && inputScore[j] >= 80) {
    countB++;
    }
    if (inputScore[j] < 80 && inputScore[j] >= 70) {
    countC++;
    }
    if (inputScore[j] < 70 && inputScore[j] >= 60) {
    countD++;
    }
    if (inputScore[j] < 60 && inputScore[j] >= 0) {
    countF++;
    }
    }
    totalGrade = countA + countB + countC + countD + countF;
    System.out.println("Total Grades" + totalGrade);
    System.out.println("A" + countA);
    System.out.println("B" + countB);
    System.out.println("C" + countC);
    System.out.println("D" + countD);
    System.out.println("F" + countF);
    }

    }

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

    // read in the command-line argument
    double c = Double.parseDouble(args[0]);
    double epsilon = 1e-15; // relative error tolerance
    double t = c; // estimate of the square root of c

    // repeatedly apply Newton update step until desired precision is achieved
    while (Math.abs(t - c/t) > epsilon*t) {
    t = (c/t + t) / 2.0;
    }

    // print out the estimate of the square root of c
    System.out.println(t);
    }

    }


    [b][link=http://www.acropolismentors.com/]Acropolismentors[/link][/b] help every student in their studies by providing them help in their projects and in their assignments.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories