So far this is what I have: /** * Created on October 14, 2009 * * @author Ab * *
ID: 3614381 • Letter: S
Question
So far this is what I have: /*** Created on October 14, 2009
*
* @author Ab
*
*The program asks the user to enter two integers.
* Then it asks three questions: what's the product of the twointegers,
* what's the quotient of the two integers, and what's theremainder
* of the division of the two integers. It inputs the answersto each
* of the question from the user, tells the user whether theanswer was correct
* or worng, and finally prints a message that depends on howmany
* correct answers the user provided.
*
*/
import java.util.Scanner;
public class homework4
{
public static void main(String[] args) {
{
String numbers = null;
String str = numbers;
Scanner keyboard = newScanner(System.in);
System.out.print("Enter somewhole numbers: ");
numbers =keyboard.toString();
while (i > 0);
{
StringindexOfi;
ObjectindexOf;
System.out.print("the number of non-zero numbers read: "+indexOf.numbers );
}
System.out.println();
}
}
}
- For each of the following questions, write a code segment thatsolves the given problem. Note that some questions provide separatesample input and output, instead of giving an example of theinteraction of the code with the user (as is given in the labassignments). The inputs and outputs may or may not be interleavedin an actual run of the code, depending on how the code isimplemented. By definition, input is whatever the user types in andthe program reads, and output is whatever the program writes to thescreen. If you are confused by this, make sure you ask yourinstructor about it as soon as possible.
- Write a program segment that reads a sequence of integers untila 0 is encountered, and outputs the number of non-zero numbersread. For example, if the input is:
2
The code will read in all the integers, and produce the followingoutput:
13
-7
21
-11
0Number of non-zero integers: 5
- Write a program segment that reads a sequence of integers untila 0 is encountered, and outputs the number of even integers and thenumber of odd integers read (not counting the final 0). Forexample, if the input is:
2
The code will read in all the integers, and produce the followingoutput:
13
-7
21
-11
0Number of even integers: 1
Number of odd integers: 4 - Write a program segment that reads a sequence of integers untila 0 is encountered. For each number read, output the number oftimes the number can be divided by 2 before you get 0. For example,if the input is:
2
The code will read in all the integers, and produce the followingoutput:
9
-7
4
-3
02
4
3
3
2
- Write a program segment that reads a sequence of integers untila 0 is encountered, and outputs the number of non-zero numbersread. For example, if the input is:
Explanation / Answer
x.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.