Question

1. What is the output of the following code? 
public class Loopy {
public static void main(String[] args) {
int x = 1;
System.out.println("Before the loop");
while (x < 4) {
System.out.println("In the loop");
System.out.println("Value of x is " + x);
x = x + 1;
}
System.out.println("This is after the loop");
}
}

2. Write a program called KiloToPoundTable that prints the below table. Use
printf()and while statement. You need to use if while statement. 

1) 1 kilogram is 2.20462 pounds (so, 2nd row will be 3 * 2.20462)
2) Use while statement to iterate
3) Set width to 12 for each column
4) Use printf() for precision up to tenths place

Kilograms Pounds
2.2
6.6
11.0
15.4
19.8
24.3
28.7
33.1
7
13
15
1) 1 kilogram is 2.20462 pounds (so, 2nd row will be 3 * 2.20462)
2) Use while statement to iterate
3) Set width to 12 for each columrn
4) Use printf) for precision up to tenths place

Image Transcription

Kilograms Pounds 2.2 6.6 11.0 15.4 19.8 24.3 28.7 33.1 7 13 15 1) 1 kilogram is 2.20462 pounds (so, 2nd row will be 3 * 2.20462) 2) Use while statement to iterate 3) Set width to 12 for each columrn 4) Use printf) for precision up to tenths place

Expert Answer

Want to see the step-by-step answer?

See Answer

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

See Answer
*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.

Related Computer Engineering Q&A

Find answers to questions asked by student like you

Q: this question is from fundamentals of logic. related to boolean algebra. I am unable to decipher the...

A: Click to see the answer

Q: I need  crow ERD Model with PK, FK and Referential integrity Arrow Electronics is a consumer electro...

A: The 8 entities are indicated below with only their unqiue identifier (underlined) and one or more ot...

Q: Write a program called StudentTable that prints the below table. Use only print() orprintf(). DO NOT...

A: The program in Java would be using print and printf statements with formatting for left alignment of...

Q: What could be the value of the register Stl after executing the instruction SLL $t1, $t0, 1 if the v...

A: A Shift left logical (SLL) of one position moves each bit to the left by one.After executing the giv...

Q: how do you known when you need to use int and float? I know that int refers to intergers and float r...

A: “input” keyword in Python:In Python, the function which is used to read the input from the keyboard ...

Q: What is the complement of the function F X7+ (X+TZ)+7? a) (XF( Z)).Y b) (X+F Z).Y c) (+ Z))Y d) .T+Z...

A: Complement of the function:The computation of complement of the given function is provided below:

Q: What is the typical HTML5 tag which is migrate from HTML4 to HTML5? <content b. <section <fragment d...

A: HTML is a markup language that defines the properties and behavior of webpage. Since the release the...

Q: Which of the following statements are true? In PC relative addressing mode, the PC and constant need...

A: In PC relative addressing mode, the effective or branch address is obtained by adding offset to PC t...

Q: Use Eclipse for this program

A:  Step 1: Import required package.Step 2: Define “AnalyzeNumbers” class.Step 3: Define main function....