2 Modify the program you created in Q31 so that the user can provide the values

2 modify the program you created in q31 so that the

This preview shows page 4 - 7 out of 7 pages.

Q3.2 Modify the program you created in Q3.1 so that the user can provide the values for pmt , i , and n through the console. import java.util.Scanner; public class PercentagePrinter
Image of page 4
Image of page 5
Q4. StringQ4 Using the substringmethod and concatenation, write a sequence of commands that will extract characters from inputString = "The quick brown fox jumps over thelazy dog"to make outputString = "Tempus fugit". Then print outputString .
Image of page 6
System.out.print(inputString.substring(22,23)); //m System.out.print(inputString.substring(23,24)); //p System.out.print(inputString.substring(5,6)); //u System.out.print(inputString.substring(24,25));//s System.out.print(inputString.substring(3,4)); // System.out.print(inputString.substring(16,17)); //f System.out.print(inputString.substring(5,6));//u System.out.print(inputString.substring(42,43));//g System.out.print(inputString.substring(6,7)); //i System.out.print(inputString.substring(31,32));//t */ String message = inputString.substring(0, 1).concat(inputString.substring(2, 3)).concat(inputString.substring(22,23)); String message2=inputString.substring(23,24).concat(inputString.substring(5,6)).concat(inputString.sub string(24,25)); String message3= inputString.substring(3,4).concat(inputString.substring(16,17)).concat(inputString.substring(5,6)) .concat(inputString.substring(42,43)).concat(inputString.substring(6,7)).concat(inputString.subst ring(31,32)); System.out.print(message+message2+message3); } }
Image of page 7

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture