Integer userinput is read from input. Write a while loop that iterates until userinput is negative....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Integer userinput is read from input. Write a while loop that iterates until userinput is negative. At each iteration: Update integer result as follows: • If userinput is not divisible by 4, output "hit" and increment result. • Otherwise, output "miss" and do not update result. Then, read an integer from input into variable userinput. End each output with a newline. Ex: If the input is 8 4 13 -5, then the output is: miss miss hit Result is 1 Note: x % 4 == 0 returns true if x is divisible by 4. 1 import java.util.Scanner; 3 public class ResultCalculator { 23456FHN34SG 7 10 11 12 13 14 public static void main(String[] args) { Scanner scnr new Scanner(System.in); int user Input; int result; 15 } 16} result = 0; userInput = scnr.nextInt (); V+Your code goes here */ System.out.println("Result is " + result); Integer numin is read from input representing the number of integers to be read next. Use a loop to read the remaining integers from input. For each integer read in the loop, output "value is "followed by the integer. End each output with a newline Ex: If the input is: 4 95 70 75 65 then the output is: value is 95 value is 70 value is 75 value is 65 1 import java.util.Scanner; 2 3 public class Values { 4 5 6 7 8 9 10 11 12 13 14 15} public static void main(String[] args) { Scanner scnr = new Scanner(System.in); } int numin; int value; int i; numIn = scnr.nextInt (); V*Your code goes here */ Integer userinput is read from input. Write a while loop that iterates until userinput is negative. At each iteration: Update integer result as follows: • If userinput is not divisible by 4, output "hit" and increment result. • Otherwise, output "miss" and do not update result. Then, read an integer from input into variable userinput. End each output with a newline. Ex: If the input is 8 4 13 -5, then the output is: miss miss hit Result is 1 Note: x % 4 == 0 returns true if x is divisible by 4. 1 import java.util.Scanner; 3 public class ResultCalculator { 23456FHN34SG 7 10 11 12 13 14 public static void main(String[] args) { Scanner scnr new Scanner(System.in); int user Input; int result; 15 } 16} result = 0; userInput = scnr.nextInt (); V+Your code goes here */ System.out.println("Result is " + result); Integer numin is read from input representing the number of integers to be read next. Use a loop to read the remaining integers from input. For each integer read in the loop, output "value is "followed by the integer. End each output with a newline Ex: If the input is: 4 95 70 75 65 then the output is: value is 95 value is 70 value is 75 value is 65 1 import java.util.Scanner; 2 3 public class Values { 4 5 6 7 8 9 10 11 12 13 14 15} public static void main(String[] args) { Scanner scnr = new Scanner(System.in); } int numin; int value; int i; numIn = scnr.nextInt (); V*Your code goes here */
Expert Answer:
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
XYZ Inc., a well-known manufacturer of inflatable boats is considering a new project, a thickened inflatable boat. Thickened boat is of higher quality and double the price of the normal inflatable...
-
Executives at Southwestern Construction have noticed that the company's construction team in the Phoenix office is more efficient with its resources than the other teams in the Las Vegas, Salt Lake,...
-
How do customer perceptions of equitys brand values compare to its competitors?
-
Write a program that takes an integer command-line argument n and creates an n-by-n boolean array a[][] such that a[i][j] is true if i and j are relatively prime (have no common factors), and false...
-
In Problem 3.55, determine the perpendicular distance between cable EF and the line joining points D and I. Problem 3.55: A mast is mounted on the roof of a house using bracket ABCD and is guyed by...
-
Roadrunner Bookstore uses the perpetual inventory system. Roadrunner Bookstore is owned by Tina Smith. The company had the following transactions for the month of September. Sep 1 Sep 2 Sep 4 Sep 5...
-
You are a salesperson for the local cell phone company presenting to the sales manager of a company considering adopting a companywide cell phone provider. Develop a 5-minute product demonstration of...
-
Whispering issued an 9%, 10-year $1,800,000 bond to build a monorail mass transit system. The city received $1,587,988 cash from the bond issuance on January 1, 2025. The bond yield is 11%. Interest...
-
During an experiment with moving sound sources, students notice a change in pitch. As a train approaches, the whistle's pitch appears higher, and as it moves away, the pitch seems lower. This change...
-
Kansas Corp., an American company, has a payment of 5 million due to Tuscany Corp. one year from today. At the prevailing spot rate of 0.90 /$, this would cost Kansas $5,555,556, but Kansas faces the...
-
How does the molecular collision theory elucidate the rate of chemical reactions, considering factors such as activation energy and collision frequency ?
-
Tony undergoes inner conflict as he struggles with his beliefs. using the venn diagram, compare and contrast what he is taught by ultima, by the priest, and by the boys who believe in the golden carp.
-
I am not asking you to tell me if you liked the content of the story but rather look at it from a videography standpoint. Pay attention to the follwing: -shot framing and composition, were the shots...
-
Discuss the application of kinetic isotope effects in elucidating reaction mechanisms and probing the nature of chemical bond-breaking and bond-forming processes, particularly in the context of...
-
What role does health communication have in public health? Provide an example of how health communication is applied in public health and the impact it has had. Describe the key features and...
-
33. Your opinion is that Boeing has an expected rate of return of 0.08. It has a beta of 0.92. The risk-free rate is 0.04 and the market expected rate of return is 0.10. According to the Capital...
-
What are three disadvantages of using the direct write-off method?
-
What general guidelines of coding has management overlooked in its decision to use a summer code for cities? Make a list of them. What is the effect on full-time data entry personnel of changing...
-
What is meant by the term entity-relationship diagram?
-
What are hypertext links? Where should they be used?
-
Consider the following binary linear programming formulation of a capital budgeting problem. \[ \begin{array}{ll} \text { Max } & 1,200 x_{1}+600 x_{2}+950 x_{3}+1,650 x_{4} \\ \text { s.t. } &...
-
A 1.0-cm-diameter sphere is charged to a potential of \(3400 \mathrm{~V}\). How much charge is on the sphere?
-
a. What is the potential difference between the terminals of an ordinary AA or AAA battery? (If you're not sure, find one and look at the label.) b. An AA battery is connected to a parallel-plate...
Study smarter with the SolutionInn App