Write a complete Java program that reads an odd number from the user. Your program should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a complete Java program that reads an odd number from the user. Your program should then use this odd number and nested for loops to print a cross made of stars. Some samples of how your program should run are shown below (user input in bold): Please enter an odd number of stars: 3 * * * * * Please enter an odd number of stars: 5 * * * * Hint: The trick is to realize that there are two cases in which you have to place a star: 1. When the row and column numbers are the same (i.e., when row = 0 and column = 0 there is a star. Same when row = 1 and column=1, etc.) 2. When the row number and the column numbers are opposites. (ex. if the user entered 7 stars, then there is a star drawn when row = 0 and column = 6, when row = 1 and column 5, etc...) Activate 3. You can also use the method you learned in the class to print the pattern. Consider the etting upper half, the middle row and the lower half separately. Write a complete Java program that reads an odd number from the user. Your program should then use this odd number and nested for loops to print a cross made of stars. Some samples of how your program should run are shown below (user input in bold): Please enter an odd number of stars: 3 * * * * * Please enter an odd number of stars: 5 * * * * Hint: The trick is to realize that there are two cases in which you have to place a star: 1. When the row and column numbers are the same (i.e., when row = 0 and column = 0 there is a star. Same when row = 1 and column=1, etc.) 2. When the row number and the column numbers are opposites. (ex. if the user entered 7 stars, then there is a star drawn when row = 0 and column = 6, when row = 1 and column 5, etc...) Activate 3. You can also use the method you learned in the class to print the pattern. Consider the etting upper half, the middle row and the lower half separately.
Expert Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Which of the following statements about close buyer-seller relationships in business markets is FALSE? Long-term commitments on larger order quantities often cause the supplier to raise its selling...
-
Paper Submarine Manufacturing is investigating a lockbox system to reduce its collection time. It has determined the following: Average number of payments per day..................385 Average value...
-
The article Abyssal Peridotites > 3,800 Ma from Southern West Greenland: Field Relationships, Petrography, Geochronology, Whole-Rock and Mineral Chemistry of Dunite and Harzburgite Inclusions in the...
-
1. Identify 3 students to play the roles of the employees. Ask these 3 individuals to read their roles below. 2. Identify 1 student to play the role of the president of the social enterprise (Taylor...
-
For Lodes Company, the relevant range of production is 4080% of capacity. At 40% of capacity, a variable cost is $4,000 and a fixed cost is $6,000. Diagram the behavior of each cost within the...
-
2. (24 Points) Find out the number of real roots of the cubic equation 23-6x+1=0. Justify your answer.
-
Read each problem carefully and show all of your work. 1) Which savings strategy is better for an account that has an APR of 4% compounded quarterly for 20 years: (Why?) a) One $4,000 deposit or b)...
-
Identify three risks , then describe mitigation measures you would take to prevent each risk from occurring (or lessening their impact). Use at least 200 words for each risk. Risk 1 [Insert Name of...
-
WyCo s fiscal year ends September 3 0 . On September 1 0 , it collects $ 3 0 , 0 0 0 for a painting job and credits Unearned Painting Revenue. As of September 3 0 , 6 0 % of the work has been done....
-
The potential macroeconomic benefits of generative artificial intelligence and machine-learning technologies are staggering, on par with transformative technologies that fed the industrial revolution...
-
BUSI 411 Extra Credit Assignment Options Instructions: Create a Word document and answer the following questions following APA formatting guidelines. Question 1 (a) Explain the term Option Greeks (b)...
-
Background: BrightFoods Inc. is a growing food distribution company that has decided to modernize its operations by implementing a new Information System (IS). The company aims to improve its...
-
Use AISC Tables to solve: A steel frame in a factory is shown in the figure below. The detail of roofing system is shown in the detail A. A corrugated sheets, heat insulating sheets and roof covering...
-
Figure displays a 12.0 V battery 3 four uncharged capacitors of capacitances C1 = 4.00F, C2 = 6.00F, and C3 = 3.00F. The switch is thrown to the left side until capacitor 1 is fully charged. Then the...
-
Write a method called showTwos that shows the factors of 2 in a given integer. For example, consider the following calls: showTwos(7); showTwos(18); showTwos(68); showTwos(120); These calls should...
-
Write a method called doubleList that doubles the size of a list by appending a copy of the original sequence to the end of the list. For example, if a variable list stores the values [1, 3, 2, 7]...
-
Suppose you have an array of integers called numbers. Write a piece of code that uses stream operations to make a new array called positives that stores only the positive integers from numbers.
-
Identify the sources and discuss the consequences of bank runs, bank panics, and financial crises.
-
Explain why and how the government intervenes in the financial system, and the problems the government safety net creates.
-
Deflation is the rate of decline in the aggregate price level. Why might unexpected deflation be of particular concern to someone managing a bank?
Study smarter with the SolutionInn App