Using netbeans write a code: Use printf. Do not use JOptionPane. Note: In format
ID: 673716 • Letter: U
Question
Using netbeans write a code:
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;
System.out.println("kilograms | pounds");
System.out.println("--------+-----------");
while(Kgs<100)
{
System.out.printf(" %3d ",kgs);
Kgs+=2;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.