What is your program public class Lab public static void mainString args double

What is your program public class lab public static

This preview shows page 8 - 11 out of 11 pages.

What is your program? public class Lab { public static void main(String[] args ) { double pmt = 10000; double i = .08; double n = 20; double pvann = ( pmt * ((((1 + i )* n - 1 - 1) / i ) / (1 + i )* n - 1 + 1)); System. out .println( pvann ); } }
Image of page 8
7.2) Modify the program you created in Lab 4.7.1 so that the user can provide the values for pmt, i, and nthrough the console. 8.1) What is the output of the following program? Why?
Image of page 9
8.2) Fix the program in Lab 4.8.1 so that it yields the correct result. double averageAge = ( double )( age1 + age2 + age3 + age4 ) / 4; 9.1) What is the output of the following program? Why?
Image of page 10
9.2) Fix the program from Lab 4.9.1 so that it displays the correct result. Remember that you can use Math.round to convert a floating-point value to its closest integer. double probability = 8.70; double percentage = (100 * probability ); System. out .println(Math. round ( percentage )); 10) Using the substring method and concatenation, write a sequence of commands that will extract characters from inputString = "The quick brown fox jumps over the lazy dog" to make outputString = "Tempus fugit". Then print outputString. public class SubstringDemo { public static void main(String[] args ) { String inputString = "The quick brown fox jumps over the lazy dog" ; String a = inputString .substring(0, 1); String b = inputString .substring(28, 29); String c = inputString .substring(22, 24); String d = inputString .substring(5, 6); String e = inputString .substring(24, 26); String f = inputString .substring(16, 17); String g = inputString .substring(21, 22); String h = inputString .substring(42, 43); String i = inputString .substring(6, 7); String j = inputString .substring(31, 32); String outputString = a + b + c + d + e + f + g + h + i + j ; System. out .println( outputString ); } } Output: Tempus fugit
Image of page 11

You've reached the end of your free preview.

Want to read all 11 pages?

  • Fall '12
  • DuiWei
  • System.out.println

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture