Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.5, Problem 6.5.2CP
Identify and correct the errors in the following
- 1. public class Test {
- 2. public static void main(Stri ng[ ] args)
- 3. nPrintln (S , "Welcome to Java!" );
- 4. }
- 5.
- 6. public static void nPrintln(Stri ng message, int n) {
- 7. int n = 1 ;
- 8. for ( int i = 0 ; i < n; i ++)
- 9. System.out.println(message);
- 10. }
- 11. }
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
light
}
What is the output of this Java program?
}
class Driver {
public static void main(String[] args) {
int a = 6:
int b = 6;
int c = 5;
int x = 1;
if (a > 2) {
}
}
if
x = x + 600;
(b> 3) {
x = x + 60;
}
if (c < 9) {
X = x + 5;
System.out.print(x);
10.
public static void methodl (int i, int num) {
for (int j = 1; j <= i; j++) {
" ");
System.out.print (num +
num *= 2;
}
System.out.println();
}
public static void main(String[] args) {
int i = 1;
while (i <= 6) {
methodl (i, 2);
i++;
}
The following code segment has an error. Find the error and suggest a correction.
Chapter 6 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
Ch. 6.4 - What are the benefits of using a method?Ch. 6.4 - Prob. 6.4.2CPCh. 6.4 - How do you simplify the max method in Listing 6.1...Ch. 6.4 - Prob. 6.4.4CPCh. 6.4 - Prob. 6.4.5CPCh. 6.4 - Prob. 6.4.6CPCh. 6.4 - Prob. 6.4.7CPCh. 6.4 - Write method headers (not the bodies) for the...Ch. 6.4 - Identify and correct the errors in the following...Ch. 6.4 - Prob. 6.4.10CP
Ch. 6.5 - Prob. 6.5.1CPCh. 6.5 - Identify and correct the errors in the following...Ch. 6.5 - Prob. 6.5.3CPCh. 6.5 - Prob. 6.5.4CPCh. 6.6 - Prob. 6.6.1CPCh. 6.6 - Prob. 6.6.2CPCh. 6.7 - What is hexCharToDecimal ( B)) ? What is...Ch. 6.8 - What is method overloading? Is it permissible to...Ch. 6.8 - What is wrong in the following program? public...Ch. 6.8 - Given two method definitions, public static double...Ch. 6.9 - Prob. 6.9.1CPCh. 6.9 - What is the scope of a local variable?Ch. 6 - (Math: pentagonal numbers) A pentagonal number is...Ch. 6 - (Sum the digits in an integer) Write a method that...Ch. 6 - (Palindrome integer) Write the methods with the...Ch. 6 - (Display an integer reversed) Write a method with...Ch. 6 - (Sort three numbers) Write a method with the...Ch. 6 - (Display patterns) Write a method to display a...Ch. 6 - (Financial application: compute the future...Ch. 6 - (Conversions between Celsius and Fahrenheit) Write...Ch. 6 - Prob. 6.9PECh. 6 - (Use the isPrime Method) Listing 6.7,...Ch. 6 - (Financial application: compute commissions) Write...Ch. 6 - (Display characters) Write a method that prints...Ch. 6 - (Sum series) Write a method to compute the...Ch. 6 - (Estimate ) can be computed using the following...Ch. 6 - (Financial application: print a tax table) Listing...Ch. 6 - Prob. 6.16PECh. 6 - Sections 6.10 and 6.11 6.17 (Display matrix of 0s...Ch. 6 - (Check password) Some Websites impose certain...Ch. 6 - (Triangles) Implement the following two methods: /...Ch. 6 - (Count the letters in a string) Write a method...Ch. 6 - (Phone keypads) The international standard...Ch. 6 - (Math: approximate the square root) There are...Ch. 6 - (Occurrences of a specified character) Write a...Ch. 6 - (Display current date and time) Listing 2.7,...Ch. 6 - Prob. 6.25PECh. 6 - (Palindromic prime) A palindromic prime is a prime...Ch. 6 - (Emirp) An emirp (prime spelled backward) is a...Ch. 6 - (Mersenne prime) A prime number is called a...Ch. 6 - (Twin primes) Twin primes are a pair of prime...Ch. 6 - (Game: craps) Craps is a popular dice game played...Ch. 6 - (Financial: credit card number validation) Credit...Ch. 6 - (Game: chance of winning at craps) Revise...Ch. 6 - (Current date and time) Invoking System....Ch. 6 - (Print calendar) Programming Exercise 3.21 uses...Ch. 6 - (Geometry: area of a pentagon) The area of a...Ch. 6 - (Geometry: area of a regular polygon) A regular...Ch. 6 - (Format an integer) Write a method with the...Ch. 6 - (Generate random characters) Use the methods in...Ch. 6 - (Geomentry: point position) Programming Exercise...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Since computers cannot be programmed in natural human language, algorithms must be written in a(n) _____ langua...
Starting Out With Visual Basic (8th Edition)
The wires each have a diameter of 12 in., length of 2 ft, and are made from 304 stainless steel. If P = 6 kip, ...
Mechanics of Materials (10th Edition)
What is the reason for using a taper tap before a plug tap in tapping a hole?
Degarmo's Materials And Processes In Manufacturing
The while loop is a _______ type of loop. a. pretest b. no-test c. prequalified d. post-iterative
Starting Out with Python (4th Edition)
Use the Web to research the history of the BASIC, C++, Java, and Python programming languages, and answer the f...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Describe a method that can be used to gather a piece of data such as the users age.
Web Development and Design Foundations with HTML5 (8th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- class operators { public static void main(String args[]) { int x = 8; System.out.println(++x * 3 + " " + x); } } Give result for the code Java Try to do ASAP ?arrow_forwardjavaarrow_forwardpublic class Test { } public static void main(String[] args){ int a = 10; System.out.println(a*a--); }arrow_forward
- class main { public static void main(String args[]) { int x =2; int y =0; for(; y <10;++y) { if(y % x ==0) continue; elseif(y ==8) break; else System.out.print(y +" "); } } } Give result for the code Java Try to do ASAParrow_forward0:1 أنت QUESTION 4 The value of i is .. . public class MidExam { public static void main (String [] args) { int j- 1; int i - j++ +j+ 6; System.out.printin("The value ofi is " + 1) : O 13 O 6 O 14arrow_forwardJava Language Please help me fix all the error. I very appreciate it Coding: import java.util.Scanner;public class Main { /*static displayline(); char line; { for (int i = 1; i < line; i++ ) { System.out.println ("_"); } } */ public static void main(String[] args) { System.out.println("Clinic Management\n"); int PatAge, Pnumber,age; int cmedicine, cost, Pcost, total, newTotal; String PatName, Pgender, Pdisease, Pmedicine; char typeofmedicine; Scanner scan = new Scanner(System.in); System.out.println("Patient Name :"); String name = scan.next(); name = name + scan.nextLine(); System.out.println("Patient Age :"); age = scan.nextInt(); System.out.println("Patient Gender :"); String gender = scan.next(); System.out.println("Patient Phone Number :"); Pnumber = scan.nextInt(); System.out.println("Patient Disease :" ); String disease =…arrow_forward
- Compute: z = y √x Ex: If the input is 4.0 3.0, then the output is: 1.0 1 import java.util.Scanner; 2 3 public class MathFunctions { 4 5 6 7 8 9 10 11 12 13 14 15 16 17} public static void main (String[] args) { Scanner scnr = new Scanner(System.in); double x; double y; double z; } X = scnr.nextDouble(); y scnr.nextDouble(); /* Your code goes here */ System.out.printf("%.1f\n", z); // This will output z with 1 decimal place. [arrow_forward- Fill the missing parts import java.math.*; public class BIE×2 { public static void main(String] args) { Biglnteger first,second, third; first = second //Multiply first and second and store in var third using Il multiply(Biglnteger(value) function third = String result = first + + second + +third; System.out.println("Multiplication: " +result); } } Explanation is Must . Thank you!!arrow_forwardFind error and correct it : public class ProgramLayout { public static void main (String[] args) { final double PI = 3.14159; double x; double sum = x+PI ; System.out.println (sum); } // end classarrow_forward
- Remaining Time: 1 hour, 28 minutes, 35 seconds. * Question Completion Status: QUESTTON 11 There are five syntax errors in the following java program. Explain them by mentioning the line number with each error. public class public static void main (String [] args) { { double a = 9; 4 double b = 9.0; int x; System.out.println ("Sum of a and b is if( a = b) + (a+b)) 80 X = a; switch (a+b) { case 0: System.out.println (x); default: System.out.println (x) ; 10 11 12 13 14arrow_forwarduse javaarrow_forwardJavaarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY