Find the error in each of the following code segments, and explain how to correct it: a)
Question:
Find the error in each of the following code segments, and explain how to correct it:
a)
i = 1;
while (i <= 10);
++i;
}
b)
for (k = 0.1; k != 1.0; k += 0.1) {
System.out.println(k);
}
c)
switch (n) {
case 1:
System.out.println("The number is 1");
case 2:
System.out.println("The number is 2");
break;
default:
System.out.println("The number is not 1 or 2");
break;
}
d) The following code should print the values 1 to 10:
n = 1;
while (n < 10) {
System.out.println(n++);
}
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 54% (11 reviews)
a Error The semicolon after the while header causes an infinite loop and theres a missi...View the full answer
Answered By
Lamya S
Highly creative, resourceful and dedicated High School Teacher with a good fluency in English (IELTS- 7.5 band scorer) and an excellent record of successful classroom presentations.
I have more than 2 years experience in tutoring students especially by using my note making strategies.
Especially adept at teaching methods of business functions and management through a positive, and flexible teaching style with the willingness to work beyond the call of duty.
Committed to ongoing professional development and spreading the knowledge within myself to the blooming ones to make them fly with a colorful wing of future.
I do always believe that more than being a teacher who teaches students subjects,...i rather want to be a teacher who wants to teach students how to love learning..
Subjects i handle :
Business studies
Management studies
Operations Management
Organisational Behaviour
Change Management
Research Methodology
Strategy Management
Economics
Human Resource Management
Performance Management
Training
International Business
Business Ethics
Business Communication
Things you can expect from me :
- A clear cut answer
- A detailed conceptual way of explanation
- Simplified answer form of complex topics
- Diagrams and examples filled answers
4.90+
46+ Reviews
54+ Question Solved
Related Book For
Java How To Program Early Objects
ISBN: 9780134743356
11th Edition
Authors: Paul Deitel, Harvey Deitel
Question Posted:
Students also viewed these Computer science questions
-
Find and correct the error in each of the following code segments: a) const int ArraySize = 5; ArraySize = 10; b) Assume var b = new int[10]; for (var i = 0; i
-
Find and correct the error in each of the following program segments: a) final int ARRAY_SIZE = 5; ARRAY_SIZE = 10; b) int[] b = new int[10]; for (int i = 0; i
-
Find the error(s) in each of the following code segments. Explain how to correct the error. a) void G() { Console.WriteLine("Inside method G"); void H() { Console.WriteLine("Inside method H"); } }...
-
1. About 99 percent of the world's population lives outside Canada, but many Canadian companies, especially small businesses, still do not engage in global trade. Why not? Do you think more small...
-
A gravitational field vector points toward Earth; an electric field vector points toward an electron. Why do electric field vectors point away from protons?
-
WACC Assignment FINA Company's assets are $750 million, financed through bank loans, bonds, preferred stocks, and common stocks. The amounts are as follows: Bank loans: $ 100 million borrowed at 7% I...
-
What is the special concern over accounting for medical malpractice claims? How does accounting for such claims compare to accounting for contingencies in a for-profit business environment?...
-
A diffraction grating has 4 200 rulings/cm. On a screen 2.00 m from the grating, it is found that for a particular order m, the maxima corresponding to two closely spaced wavelengths of sodium (589.0...
-
Direct Computation of Nonoperating Return with Noncontrolling Interest Balance sheets and income statements for Costco Wholesale Corporation follow. In 2018, Costcos return on equity (ROE) is 26.59%...
-
Tracer Advance Corporation (TAC) sells a tracking implant that veterinarians surgically insert into pets. TAC began January with an inventory of 400 tags purchased from its supplier in November last...
-
a) Sum the odd integers between 1 and 99, using a for statement. Assume that the integer variables sum and count have been declared. b) Calculate the value of 2.5 raised to the power of 3, using the...
-
Compare and contrast the while and for iteration statements.
-
How do your answers for 1, 2, and 3 change for a constructive fraud cause of action?
-
Write a function that takes as input a non-negative integer in the range 0 to 99 and returns the English word(s) for the number as a string. Multiple words should be separated by a space. If the...
-
The Event Manager sighed as the festival approached and she had only five crafts vendors who had committed to taking part in the marketplace. She and her assistant were frantic. They had been...
-
the systematic recording, analysis, and interpretation of costs incurred by a business. Its significance extends beyond mere financial tracking; it plays a pivotal role in aiding management...
-
1.What is your process for ensuring that all your work is correct? 2.What do you mean by Batch Costing ? 3.Explain the accounting procedure for Batch Costing 4.State the applicability of Job Costing...
-
The increasing occurrence of freak weather incidents will have both local and global effects. Even in cases where production has been re-localized, freak weather can still greatly impact local...
-
Ad-blocking software attachments to Web browsers enable a Web surfer to visit Web sites without having to view the pop-up advertisements associated with these Web pages. Debate this proposition:...
-
Per Bag Direct materials: 25 pounds of CWhiz-2000 @ $0.08/lb. = $ 2.00 Direct labor: 0.05 hour @ $32.00/hr. = $ 1.60 The company manufactured 100,000 bags of Cheese-Be-Good in December and used...
-
Assume the following register contents: $t0 = 0xAAAAAAAA, $t1 = 0x12345678 1. [5] For the register values shown above, what is the value of $t2 for the following sequence of instructions? 2. For the...
-
The following instruction is not included in the MIPS instruction set: rpt $t2, loop # if(R[rs]>0) R[rs]=R[rs]1, PC=PC+4+BranchAddr 1. If this instruction were to be implemented in the MIPS...
-
Consider the following MIPS loop: 1. Assume that the register $t1 is initialized to the value 10. What is the value in register $s2 assuming $s2 is initially zero? 2. For each of the loops above,...
-
Oct. 31: Paid salaries, $45,000 ( 75% selling, 25% administrtive). Data table Data table them to retail stores. The company has three inventory items: and floor lamps. RLC uses a perpetual inventory...
-
question 1- You borrow a simple loan of SR 500,000, interest rate is 20%, it matures in one year. what's the yied to maturity? question 2- calculate_i for One-Year Discount Bond with price(p) =...
-
Taste of Muscat is a reputed chain of restaurants operating in Oman. Assume You are working as a management accountant for this restaurant chain which is specialized in all types of Arabic food. Your...
Study smarter with the SolutionInn App