Using netbeans write a code for java Use printf. Do not use JOptionPane. Note: I
ID: 673713 • Letter: U
Question
Using netbeans write a code for java
Use printf. Do not use JOptionPane.
Note: In formatted printing
is TAB
is LINEFEED
(Conversion of kilograms to pounds) Write a program that displays the following table (note 1 kilogram is 2.2 pounds)
Kilograms Pounds
1 2.2
3 6.6
...
197 433.4
199 437.8
Hint: The following code will print out odd integers from 1 to 99:
public class PrintOdds {
public static void main(String[] args){
int kgs=1;
while(kgs < 100){
System.out.printf(" %3d ",kgs);
kgs+=2;
}
}
Explanation / Answer
public class PrintOdds {
public static void main(String[] args){
int kgs=1;
Double pounds;
System.out.printf(" Kilograms Pounds ");
while(kgs < 200){
pounds=kgs*2.2;
System.out.printf(" %3d %3f ",kgs,pounds);
kgs+=2;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.