What does the following program print? public class Mystery { public static void main(String[] args) { int
Question:
What does the following program print?
public class Mystery {
public static void main(String[] args) {
int x = 1;
int total = 0;
while (x <= 10) {
int y = x * x;
System.out.println(y);
total += y;
++x;
}
System.out.printf("Total is %d%n", total);
}
}
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 61% (13 reviews)
1 4 9 16 ...View the full answer
Answered By
Madhvendra Pandey
Hi! I am Madhvendra, and I am your new friend ready to help you in the field of business, accounting, and finance. I am a College graduate in B.Com, and currently pursuing a Chartered Accountancy course (i.e equivalent to CPA in the USA). I have around 3 years of experience in the field of Financial Accounts, finance and, business studies, thereby looking forward to sharing those experiences in such a way that finds suitable solutions to your query.
Thus, please feel free to contact me regarding the same.
5.00+
1+ Reviews
10+ 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
-
What does the following program segment output? d = 0; do { System.out.print(d + " "); d++; } while (d < 2); a. 0 b. 0 1 c. 0 1 2 d. Nothing
-
What does the following program segment output? for(f = 0; f < 3; ++f) for(g = 0; g < 2; ++g) System.out.print(f + " " + g + " "); a. 0 0 0 1 1 0 1 1 2 0 2 1 b. 0 1 0 2 0 3 1 1 1 2 1 3 c. 0 1 0 2 1 1...
-
What does the following program segment output? for(m = 0; m < 4; ++m); for(n = 0; n < 2; ++n); System.out.print(m + " " + n + " "); a. 0 0 0 1 1 0 1 1 2 0 2 1 3 0 3 1 b. 0 1 0 2 1 1 1 2 2 1 2 2 c. 4...
-
Dwights preferences over beer and whiskey satisfy more is better, but are concave (thus violating the usual assumption of convexity). a. On a diagram, sketch what such indifference curves would look...
-
Atomic physicists ignore the effect of gravity within an atom. To see why, calculate and compare the gravitational and electrical forces between an electron and a proton separated by 10-10 m. The...
-
Shortening the credit period A firm is contemplating shortening its credit period from 40 to 30 days and believes that, as a result of this change, its average collection period will decline from 47...
-
Explain the financial impact of medical malpractice claims on governmental and private health care service providers. AppendixLO1
-
The Board Shop, owned by Andrew John, sells skateboards in the summer and snowboards in the winter. The shop has an August 31 fiscal year end and uses a perpetual inventory system. On August 1, 2017,...
-
What is the period used and period rate?
-
M. Bot Corporation has 10,000 shares of 8%, $100 par value, cumulative preferred stock outstanding at December 31, 2020. No dividends were declared in 2018 or 2019. If M. Bot wants to pay $375,000 of...
-
Identify and correct the errors in each of the following pieces of code. a) int x = 1, total; while (x
-
What does the following program print? public class Mystery2 { public static void main(String[] args) { int count = 1; while (count
-
How would things change if land were not an input into production? In particular, how would the conclusions regarding how an increase in pollution would effect wages and land rents change?
-
What is the logical ending point of a sequential game that starts at position (2,8) with player 1 moving first? Show your work. Player 1 Strategy B Strategy A Strategy A Player 2 Strategy B (3,4)...
-
Problem A-6 Income and Retained Earnings Statements Peanut Corporation is a private corporation using ASPE. At December 31, 2017, an analysis of the accounts and discussions with company officials...
-
8.5 Area Between Curves (dy) Calculus-Calculator Allowed Mastery Check #2 Name: Date: Period: For 1-2, find the area of the region bounded by the following curves. Show the integral set up with...
-
Your company has a travel policy that reimburses employees for the "ordinary and necessary" costs of business travel. Employees often mix a business trip with pleasure by either extending the time at...
-
Simulation A: 1 Diameter 600 mm 2 Focal Length 1800 mm 3 F/D Ratio 3 4 Eyepieces 30 m 5 Barlow? N 6 Celestial Sights M42 - M31 - M51 Simulation B: 1 Diameter 150 mm 2 Focal Length 1800 mm 3 F/D Ratio...
-
The current legal system allows both proprietary software and open-source software to be distributed. What are the pros and cons of maintaining the status quo?
-
From the choice of simple moving average, exponential smoothing, and linear regression analysis, which forecasting technique would you consider the most accurate? Why? please write it in word...
-
Th is Exercise examines the single error correcting, double error detecting (SEC/DED) Hamming code. 1. What is the minimum number of parity bits required to protect a 128-bit word using the SEC/DED...
-
For a high-performance system such as a B-tree index for a database, the page size is determined mainly by the data size and disk performance. Assume that on average a B-tree index page is 70% full...
-
As described in Section 5.7, virtual memory uses a page table to track the mapping of virtual addresses to physical addresses. This exercise shows how this table must be updated as addresses are...
-
Ray Company provided the following excerpts from its Production Department's flexible budget performance report. Required: Complete the Production Department's Flexible Budget Performance Report....
-
Problem 1 5 - 5 ( Algo ) Lessee; operating lease; advance payment; leasehold improvement [ L 0 1 5 - 4 ] On January 1 , 2 0 2 4 , Winn Heat Transfer leased office space under a three - year operating...
-
Zafra and Stephanie formed an equal profit- sharing O&S Partnership during the current year, with Zafra contributing $100,000 in cash and Stephanie contributing land (basis of $60,000, fair market...
Study smarter with the SolutionInn App