Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Start BlueJ and create the project lab 0 2 under your cm 1 1 1 lab folder. Complete the programming exercises that follow. To automatically

Start BlueJ and create the project lab02 under your cm111lab folder. Complete the programming exercises that follow.
To automatically clear the terminal when you execute you program, in the project window, click the View menu and select Show terminal (or go to terminal window if open). Click on the Options menu in the terminal window and click on "Clear screen at method call".
Programming Exercises.
1. Create a class called Test. Then type the following code into the class. Note: dont forget to delete the extra lines of code that were generated by BlueJ. Compile the program and execute it. Notice the different output generated by each printf statement. This occurs because the equation in the first printf is quoted and treated as a String whereas the second printf equation is not quoted and thus executed before being printed.
public class Test {
public static void main( String[] args)
{
System.out.printf("3.5*4/22.5 is: ");
System.out.printf("%2.2f%n",3.5*4/2-2.5);
}
}
2. Create a new class called DisplayJava (in the same lab02 project). Declare four String variables: line1, line2, line3, and line4. Initialize each String variable with text to produce the result below. Think about using a 4x28 grid to do the layout on paper first. The main method should display the following pattern in the terminal window.
3. Create a new class called Rectangle (in the same lab02 project). The main method should output your name, lab number, and the output of the calculation for the area of a rectangle and the perimter. Create the variables width, length, area, and perimeter of Type Double. Use the numbers 2.5 for width and 4.0 for length for initial valuses.
Remember the area of a rectangle is width * length and the perimeter is 2* width +2* length.
Here is the expected output:
Name: , Lab#: 2
The area of a rectangle with length 4.0 and width 2.5 is: 10.00
The perimeter of a rectangle with length 4.0 and width 2.5 is: 13.00
Upon completion of these exercises show the instructor then upload DisplayJava.java and Rectangle.java to D2L.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago