Home Insert Design Layout References Mailings Review View Office Update To keep
ID: 3880113 • Letter: H
Question
Home Insert Design Layout References Mailings Review View Office Update To keep up-to-date with security updates, fixes, and limprovements, choose Check for Updates What does this program print? Pay close attention to spaces. public class Test public static void main(String[] args) System.out.print("Hel1o"); System.out.println("World"); What is the compile-time error in this program? public class Test public static void main(String[] args) System.out.printlnC Hello", "World!"): How do you discover syntax errors? How do you discover logic errors? Write an algorithm to settle the following question: A bank account starts out with $10,000. Interest is compounded monthly at 6 percent per year (0.5 percent per month). Every month, $500 is withdrawn to meet college expenses. After how many years is the account depleted? ge 1 of 2 2 Words I English (US)Explanation / Answer
Output: HelloWorld!
Error: no suitable method found for println(String,String)
println is a method that has only one argument. If we want to print HelloWorld, then we have to use a + symbol.
class Main {
public static void main(String[] args) {
// DECLARING variables
double p = 10000;
int rate = 6;
int expenses = 500;
int soFar = 0;
int month;
// looping as long as we have more than 500
for(month=1; p>=500; month++)
{
// for expenses
p = p-500;
// adding interest
p = (1+((rate/12.0)/100.0))*p;
// printing for each month
System.out.printf("Month%d - %.2f ",month, p);
}
// printing final output
System.out.println(" Totally "+month+" months.");
System.out.printf("Years : %d and Months: %d",month/12, month%12);
}
}
/*SAMPLE OUTPUT
Month1 - 9547.50
Month2 - 9092.74
Month3 - 8635.70
Month4 - 8176.38
Month5 - 7714.76
Month6 - 7250.84
Month7 - 6784.59
Month8 - 6316.01
Month9 - 5845.09
Month10 - 5371.82
Month11 - 4896.18
Month12 - 4418.16
Month13 - 3937.75
Month14 - 3454.94
Month15 - 2969.71
Month16 - 2482.06
Month17 - 1991.97
Month18 - 1499.43
Month19 - 1004.43
Month20 - 506.95
Month21 - 6.99
Totally 22 months.
Years : 1 and Months: 10
*/
Note: 4 subparts at a time please -- Chegg Policy
Output: HelloWorld!
- In the first statement we are printing Hello
- In the second statement we are printing World! along with a new line
Error: no suitable method found for println(String,String)
println is a method that has only one argument. If we want to print HelloWorld, then we have to use a + symbol.
- Syntax errors can be found at the compile time
- Logic errors can be found at the compile time
class Main {
public static void main(String[] args) {
// DECLARING variables
double p = 10000;
int rate = 6;
int expenses = 500;
int soFar = 0;
int month;
// looping as long as we have more than 500
for(month=1; p>=500; month++)
{
// for expenses
p = p-500;
// adding interest
p = (1+((rate/12.0)/100.0))*p;
// printing for each month
System.out.printf("Month%d - %.2f ",month, p);
}
// printing final output
System.out.println(" Totally "+month+" months.");
System.out.printf("Years : %d and Months: %d",month/12, month%12);
}
}
/*SAMPLE OUTPUT
Month1 - 9547.50
Month2 - 9092.74
Month3 - 8635.70
Month4 - 8176.38
Month5 - 7714.76
Month6 - 7250.84
Month7 - 6784.59
Month8 - 6316.01
Month9 - 5845.09
Month10 - 5371.82
Month11 - 4896.18
Month12 - 4418.16
Month13 - 3937.75
Month14 - 3454.94
Month15 - 2969.71
Month16 - 2482.06
Month17 - 1991.97
Month18 - 1499.43
Month19 - 1004.43
Month20 - 506.95
Month21 - 6.99
Totally 22 months.
Years : 1 and Months: 10
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.