Question
Please answer both questions. Thanks
Question 26 (1 point) What is the output generated by the code segment below, assuming that data is a Scanner object used to
Question 27 (1 point) Assuming that the user provides 114 as input, what is the output of the following code snippet? Please
0 0
Add a comment Improve this question Transcribed image text
Answer #1

26. Delimiter is used here to show that the words are space separated, hasNext returns true is the scanner has another token for the input, else it returns false. The spaces are considered as delimiter so they won't be accounted for. In the while loop the count could have been incremented only by "." but this also won't happen because hasNext for this will give false and we will come out of the while loop. So the count remains 0.

Output will be : 0

27. Assuming that the user provides y as 114 as the input, we see that 114<200 i.e. y<200, we will change x to x+y i.e. x = 19+114 = 133.

The output will be : x: 133

Add a comment
Know the answer?
Add Answer to:
Please answer both questions. Thanks Question 26 (1 point) What is the output generated by the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 47 (1 point) What is the output generated by the code segment below, assuming that...

    Question 47 (1 point) What is the output generated by the code segment below, assuming that source is a Scanner object used to read the following text: Suzy sells seashells on the seashore. source.useDelimiter(" "); int count = 0; while (source.hasNext()) { char input = source.next().charAt(0); if (Character.isLetter (input)) count++; { } System.out.println(count); A/

  • Please answer both questions thank you. Assuming that a user enters 8, 15, and 11 as...

    Please answer both questions thank you. Assuming that a user enters 8, 15, and 11 as input values one after another, separated by spaces, what is the output of the following code snippet? int num1 = 0; int num2 = 0; int num3 = 0; Scanner in = new Scanner (System.in); System.out.print("Enter a number: "); numl - in.nextInt(); System.out.print("Enter a number: "); num2 = in.nextInt(); System.out.print("Enter a number: "); num3 = in.nextInt(); if (numl > num2) if (numl > num3)...

  • For the below code find and fix the errors then tell what the output would be....

    For the below code find and fix the errors then tell what the output would be. import java.utils.*; public class pin public void main(String[] args); { char s; int num; Scanner br = Scanner(System.in); System.out.print("Enter the first letter of your name :"); s = BR.next().charAt(0); num = s; System.out.println(“The value associated with your letter is” num); }

  • Please answer both questions. Thanks Question 24 (1 point) What value would be returned if the...

    Please answer both questions. Thanks Question 24 (1 point) What value would be returned if the method mystery were called and passed the array values (1, 15, 37, 12) as its parameter? public static int mystery (int[] list) int x = 0; for (int i = 1; i < list.length; i++) { int y = list[i] - list [0]; if (y > x) x = Y } } return x; 29 35 1 36 Question 25 (1 point) What is...

  • Please answer both questions thank you. Question 52 (1 point) What is the output of the...

    Please answer both questions thank you. Question 52 (1 point) What is the output of the code snippet given below? String s = "abcde"; int i = 1; while (i < 5) { System.out.print(s.substring(i, i + 1)); i++; Question 50 (1 point) How many times will the output line be printed in the following code snippet? Please enter your answer as an integer. for (int i = 0; i < 3; i++) { for (int j = 1; j <...

  • 1. What is the output of each of the following code segments if the inputs are...

    1. What is the output of each of the following code segments if the inputs are as follows: 5 0 15 -5 2 Scanner input = new Scanner(System.in); int sum = 0; for(int i = 0; i < 5; i++){ System.out.print( “Enter a number”); int number = input.nextInt(); if(number <= 0) break; sum += number; } System.out.println(sum); Second Segment: Scanner input = new Scanner(System.in); int sum = 0; for(int i = 0; i < 5; i++){ System.out.print( “Enter a number”);...

  • Please, modify the code below to use the Switch Statements in Java instead of “if” statements...

    Please, modify the code below to use the Switch Statements in Java instead of “if” statements to make the decisions. import java.util.Scanner; public class Area { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter code(C for circle, R for rectangle, S for square): "); char code = in.next().charAt(0); if(code == 'C') { System.out.print("Enter radius: "); double radius = in.nextDouble(); System.out.println("Area of circle is " + (Math.PI * radius * radius)); } else if(code == 'R') {...

  • I need help on creating a while loop for my Java assignment. I am tasked to...

    I need help on creating a while loop for my Java assignment. I am tasked to create a guessing game with numbers 1-10. I am stuck on creating a code where in I have to ask the user if they want to play again. This is the code I have: package journal3c; import java.util.Scanner; import java.util.Random; public class Journal3C { public static void main(String[] args) { Scanner in = new Scanner(System.in); Random rnd = new Random(); System.out.println("Guess a number between...

  • What would be the output if 1, 2, 3, and -1 were entered and please walk...

    What would be the output if 1, 2, 3, and -1 were entered and please walk me through the process. import java.util.Scanner; public class Practice1 { public static void main(String[] args) { int count = 0; int sum = 0; Scanner keyboard = new Scanner(System.in); System.out.println("Enter integers or -1 to quit"); int anInt = keyboard.nextInt(); while(anInt != -1) { anInt = keyboard.nextInt(); sum += anInt; count++; } anInt = keyboard.nextInt(); sum += anInt; count++; } }

  • (a)How many times does the code snippet given below display "Hello"? int x = 1; while...

    (a)How many times does the code snippet given below display "Hello"? int x = 1; while (x != 15) {    System.out.println ("Hello");    x++; } (b)What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 5) {    sum = sum + i;    i++; } System.out.println("The value of sum is " + sum); Quie 2 What is the output of the following snipped code? public class Test {...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT