1. Consider the following code Scanner se - new Scanner(System.in); System.out.println("Do you think exams are fun7") st

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. Consider the following code Scanner se - new Scanner(System.in); System.out.println("Do you think exams are fun7") st

Post by answerhappygod »

1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 1
1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 1 (34.73 KiB) Viewed 35 times
1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 2
1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 2 (46.38 KiB) Viewed 35 times
1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 3
1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 3 (46.38 KiB) Viewed 35 times
1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 4
1 Consider The Following Code Scanner Se New Scanner System In System Out Println Do You Think Exams Are Fun7 St 4 (24.29 KiB) Viewed 35 times
1. Consider the following code Scanner se - new Scanner(System.in); System.out.println("Do you think exams are fun7") string = c.nextLine it is.equals("yes") System.out.print Really?) else if(s.equals("no")) (String 12 - new Stringime neither"); System.out.print (2) How many classes. Objects. Methods does the code contain? 2. For each of the following codes, write the output or state the error is the code would not run. Code: foscant - ! < 3) for(int 1 - 8:11 - 2) System.out.print() Code : chat - Lot 1 - 103 Stringat myString": Syatem.out.printlnat) Code CA int sun - 0: tort int 1-0+ 161005 1-2) System.out.printtnt) 2. The Fibonacci sequence is defined such that a number in the sequence is the sum of the previous two number in the sequence where the first two numbers are 0.1 The Fibonacel sequence is:0. 1. 1. 2. 3,5,8. 13.21. - Write a method, fijava that takes an integer as argument and outputs the Fibonacci sequence to the first value greater than the input. Example: bjava/6] would display 0. 1. 1. 2.3.5.8 4. Write some code that will declare, initialize, and fill in an array of type int. After your code executes, the array should look as follows: 0 2 4 6 8 10 12 14 16 18 5. Consider a rectangular grid of size 100x100. Each square in the grid has a unique row and column number ( vl. The square (0.03 is at the middlex values increase to the right and decrease to the left y values increase going down and decrease going up. We want to create a Robot class. Each Robot object represents one robot. Each robot has a location vi, and a direction in which it is facing (up. right, down, or left). A robot can move one square forward in the direction it is facing. It can also turn 90 degrees to the right. In addition, we shall be able to know a robot's current and y position and direction. Write the Robot class that includes the data and behavior needed as described.

1. Consider the following code: Scanner sc - new Scanner (System.in); System.out.println("Do you think exams are fun?"); String s - sc.nextLine(); if (s.equals("yes") { System.out.print("Really?"); } else if(s.equals("no")) { String s2 - new String ("me neither"); System.out.print(s); } How many Classes, Objects, Methods does the code contain? 2. For each of the following codes, write the output or state the error is the code would not run. Code A: for (int i = 1; i < 8; i +3) for(int j = 0; j > i; j -- 2) System.out.print() + " "); Code B: char c-'A'; int i = 10; String str - "myString": str += c + i; System.out.println (str); Code C: int sum = 0; for(int i=0; i<100; i+=2) ( sum += i;) System.out.println( i ); 3. The Fibonacci sequence is defined such that a number in the sequence is the sum of the previous two number in the sequence where the first two numbers are 0, 1. The Fibonacci sequence is: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... Write a method, fib_java that takes an integer as argument and outputs the Fibonacci sequence to the first value greater than the input. Example: fib_java(6) would display 0,1,1,2,3,5,8 4. Write some code that will declare, initialize, and fill in an array of type int. After your code executes, the array should look as follows: 0 2 4 6 8 10 12 14 16 18

5. Consider a rectangular grid of size 100x100. Each square in the grid has a unique row and column number (x, y). The square (0, 0) is at the middle; x values increase to the right and decrease to the left; y values increase going down and decrease going up. We want to create a Robot class. Each Robot object represents one robot. Each robot has a location (x, y), and a direction in which it is facing (up. right, down, or left). A robot can move one square forward in the direction it is facing. It can also turn 90 degrees to the right. In addition, we shall be able to know a robot's current x and y position and direction. Write the Robot class that includes the data and behavior needed as described.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply