(Solved) : Ouble Num1 1234567456 Num2 123456 Num3 123456 Num4 123456789 Int Num5 123456 String Name J Q41399869 . . .

ouble num1 = 1234567.456, num2 = 123.456, num3 = 123.456, num4 =123456.789;

int num5 = 123456;

String name = “James”;

Write a program that includes the following statements:

1.       A printf statement thatdisplays the value of num1 formatted as: 1,234,567.46

2.       A printf statement thatdisplays the value of num2 rounded to one decimal place, in a fieldthat is ten spaces wide (Do not use comma separators).

3.       A printf statement thatdisplays the value of num3 padded with leading zeros, in a fieldthat is eight spaces wide, rounded to one decimal place (Do not usecomma separators).

4.       A printf statement thatdisplays the value of num4, left-justified, with comma separators,in a field that is 20 spaces wide, rounded to two decimalplaces.

5.       A printf statement thatdisplays the value of num5 in a field that is 10 spaces wide, withno comma separators.

6.       A printf statement thatdisplays the value of name in a field that is 20 spaces wide.

Expert Answer


Answer to ouble num1 = 1234567.456, num2 = 123.456, num3 = 123.456, num4 = 123456.789; int num5 = 123456; String name = “James�…