Write, compile, and test a class that displays your first name on the screen. Save the class as Name.
PROGRAM
//class definition
public class Name {
//main function definition
public static void main(String[] args) {
//print the first name
System.out.println("Jonathan");
}
}
OUTPUT

Write, compile, and test a class that displays your full name, street address and city, on three separate lines on the screen. Save the class as Address.
PROGRAM
//class definition
public class Address {
//main function definition
public static void main(String[] args) {
//print full name
System.out.println("Jonathan
Dixon");
//print street
System.out.println("Street number
66");
//print city
System.out.println("New
York");
}
}
OUTPUT

Write a java program which add two numbers and print the result on screen. Save the class as Add2.
PROGRAM
//class definition
public class Add2 {
//main function definition
public static void main(String[] args) {
// declare and initialize
variables
int a = 10, b =20;
int sum;
//calculate sum
sum = a+b;
//print sum
System.out.println("Sum : "
+sum);
}
}
OUTPUT

Write a java program which accepts two numbers from user multiply them and print the result on screen. Save the class as Multiply2.
//class definition
public class Multiply2 {
//main function definition
public static void main(String[] args) {
// declare and initialize
variables
int a = 10, b =20;
int product;
//calculate sum
product = a*b;
//print sum
System.out.println("Product : "
+product);
}
}
NOTE : Answered the first 4 question as per HomeworkLib policy
Write, compile, and test a class that displays your first name on the screen. Save the...
Write, compile, and test a class that displays your initials on the screen. Compose each initial with five lines of initials, as in the following example: my initals are GR Save the class as Initial.java GGGGG RRRRRR G R R G GGG R RRRR G G R R GGGGG R R
.Need code for my java class !! Write a simple java program that uses loops. You may use ‘WHILE’ or ‘FOR’ or ‘DO-WHILE’ – you decide. The program should use a loop to compute the semester average for up to 5 students. In the loop the user will ask for a student name and their 3 test scores and add them up and divide the total by 3 giving the semester average. You will print out the student name and...
Room Class....... in JAVA!!!!! Write a class named Room that has the following fields: Length: Double variable that holds the rooms length(in feet). Breadth: The double variable that holds the rooms breadth(in feet). Height: Double variable that holds rooms height in feet. Color: String object that holds the color you want the room to be painted with. The class should have a constructor to initialize the fields for a particular instance (or object) of the class as given: All double...
Java only please Write a program that displays the following menu: Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Triangle 3. Calculate the Area of a Rectangle 4. Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the formula: area = ∏r2 Use 3.14159 for ∏. If the user enters 2 the program should ask for...
Need to solve this program which will run exactly like sample
run .. Thanks
Project 2 Using Classes and Objects (Chapter 3) Duc: sec calendar Two files to be submitted: . Algorithm of method main (AlgorithmOfMain.txt, no credit if this is missing) Java Source code (CarpetBill.java- no credit if this has syntax errors) Write a program that creates customers' bills for a carpet company when the information below is given: irst name .Length and width of the carpet in feet...
Write a JAVA program that declares a class Pet With three variables Name, Age, weight .The class has different constructors the first without parameters ,the second with three parameters and the third with two parameters. In the main method create three objects using thee different constructors to initialize the Variables. then print out all the information a bout all objects .
java program: Write a program which displays the following list on the screen and asks the user to enter either 1 or 2 and perform one of the operations based on the user’s input. If the user enters any other character other than 1 or 2 then display “wrong choice”. LIST OF OPERATIONS 1. Buzz Number 2. Consecutive Odd numbers Note: A BUZZ number is a number which either ends with 7 or is divisible by 7. Sample input 27...
EXERCISES: if & if...else STATEMENTS: Name Examples of if and if-else statements: Write an if statement that multiplies payRate by 1.5 iſ hours is greater than 40. Write variable declarations for the variables payRate and hours first. Hint: Look for keyword if first, your boolean comes after the keyword [. This translates into Java as: double hours, payRate; if (hours > 40) { //{-} are optional here but I recommend that you them payRate = payRate 1.5; pay Rato pay...
3. Write a script (name it /opt/book/ scripting /results/exercise3) which: a. Asks the user for the length and width (in feet) of a rectangular room b. Calculates the area of the room c. Displays the result to the user [Show the ouput via screenshot]
JAVA CODE This program causes an error and crashes. Compile and give it a test run, note the exception that is thrown. Then do the following to fix the problem 1. Write code to handle this exception 2. Use try, catch and finally blocks. 3. Display, the name of the exception 4. Display a message from the user about what happened. Here is the starting file BadArray.java: public class BadArray { public static void main(String[] args) { // Create an...