Answers:
1.
String line1,line2;
line1="Blessed are you whose worthness gives scope,\n";
line2="Being had, to triumph; being lacked, to hope.";
System.out.println(line1+""+line2);
2.
int width,height;
width=5;
height=5;
System.out.println("Width of rectangle is "+width);
System.out.println("height of rectangle is "+height);
3.
width=4;
height=4;
System.out.println("Width of rectangle is "+width);
System.out.println("height of rectangle is "+height);
4.
System.out.println("Area of rectangle is "+(width*height));
5.
width += 10;
height -= 3;
System.out.println("Area of rectangle is "+(width*height));
6.
byte by1[],by2[];
short s1,s2;
int i1,i2;
long l1, l2;
float f1,f2;
double d1,d2;
char ch1, ch2;
String str1,str2;
boolean b1,b2;
7.
System.out.println(10+(7%3)-12/8);
Program:
public class Program
{
public static void main(String args[])
{
//1.
String line1,line2;
line1="Blessed are you whose worthness gives scope,\n";
line2="Being had, to triumph; being lacked, to hope.";
System.out.println(line1+""+line2);
//2.
int width,height;
width=5;
height=5;
System.out.println("Width of rectangle is "+width);
System.out.println("height of rectangle is "+height);
//3.
width=4;
height=4;
System.out.println("Width of rectangle is "+width);
System.out.println("height of rectangle is "+height);
//4.
System.out.println("Area of rectangle is "+(width*height));
//5.
width += 10;
height -= 3;
System.out.println("Area of rectangle is "+(width*height));
//6.
byte by1[],by2[];
short s1,s2;
int i1,i2;
long l1, l2;
float f1,f2;
double d1,d2;
char ch1, ch2;
String str1,str2;
boolean b1,b2;
//7.
System.out.println("10+(7%3)-12/8 = "+(10+(7%3)-12/8));
}
}
We should use “Java” language. Java Eclipse :) Fall 2019 1. Assign each line to a...
JAVA 1. Write a class called Rectangle that represents a rectangular two-dimensional region. Your Rectangle objects should have the following fields and methods: int width, int height Where width and height are the dimensions of the rectangle. Write accessor methods (i.e. getWidth(), getHeight()) that retrieve the values stored in the fields above. And mutator methods (i.e. setWidthl), setHeight() ) that change the field's values. Finally create a method called getAreal) that returns the area of the rectangle. Like we did...
/*hello everyone. my question is mostly related to the garagetest part of this assignment that i've been working on. i am not sure how to read the file's contents AND put them into variables/an array. should it be in an arraylist? or maybe a regular array? or no arrays at all? i am also not sure how to call the factory method from garagec. i'm thinking something along the lines of [Garage garage = new GarageC.getInstance("GarageC", numFloors, areaofEachFloor);] but i...
could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...