Question: Methods Exercises(java) Write the exercises you did for Exercises 1 and break them into Methods. You should have at least five methods when you turn
Methods Exercises(java) Write the exercises you did for Exercises 1 and break them into Methods. You should have at least five methods when you turn in the assignment.
the exercise code:
public class Exercise1 {
public static void main (String[] args) { // exercise: 1 int side = 0; side = 0; int square = 0; square = side * side; System.out.println(" area of square with side length " + side + " is " + square); // exercise: 2 int length = 0; length = 3; int width = 0; width = 5; int rectangle = 0; rectangle = length + length + width + width; System.out.println(" preletter of of a rectangle with width " + width + " length " + length + " is " + rectangle); // exercise: 3 double base = 0; double height = 0; base = 4; height = 2; double triArea = 0; triArea = (0.5) * base * height; System.out.println(" area of trangle with base " + base + " height " + height + " is " + triArea); //Exercise: 4 int Firhr = 0; Firhr = 95; double Cel = 0; Cel = ( Firhr - 32 ) / ( 5.0 / 9.0 ); System.out.println( Firhr + " degree Firhr is converted to " + Cel + " degree "); //exercise: 5 int x = 0; int y = 0; int z = 0; x = 2; y = 2; z = x % y; System.out.println(" the mod of x " + x + " and " + y + " is " + z ); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
