Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please I need help ASAP!. Please answe all or none. Its a java course. Please were it says save answer thats were the answers should

Please I need help ASAP!. Please answe all or none. Its a java course. Please were it says save answer thats were the answers should go. Thank you

Q2.2

3 PointsGrading comment:

Why is converting a value of a smaller type to a value of a larger type (i.e., a "widening" conversion) considered "safer" than the converse (a "narrowing" conversion)?

Save Answer

Q2.3

3 PointsGrading comment:

If we know that boolean A is false but do not know if boolean B is true or false, then:

We do know A && B is false...

...but we do not know whether B || A is true or false.

Please briefly explain why this is so:

Save Answer

Q2.4

3 PointsGrading comment:

Which of the three types of loops (while, do-while, and for) is best suited for working with arrays?

Grading comment:

Why?

Save Answer

Q3

10 PointsGrading comment:

For each of the following, indicate if it is a valid Java identifier or not. (An identifier is any word you use in a program, not just a variable name.)

If it is valid, explain what it would identify using the normal naming conventions.

If it is not valid, explain why it is not valid.

Q3.1

2 PointsGrading comment:

nine

Valid?

Choice 1 of 2:YesChoice 2 of 2:No

Grading comment:

Explanation:

Save Answer

Q3.2

2 PointsGrading comment:

Product

Valid?

Choice 1 of 2:YesChoice 2 of 2:No

Grading comment:

Explanation:

Save Answer

Q3.3

2 PointsGrading comment:

this~other

Valid?

Choice 1 of 2:YesChoice 2 of 2:No

Grading comment:

Explanation:

Save Answer

Q3.4

2 PointsGrading comment:

MAXIMUM

Valid?

Choice 1 of 2:YesChoice 2 of 2:No

Grading comment:

Explanation:

Save Answer

Q3.5

2 PointsGrading comment:

92ndStreet

Valid?

Choice 1 of 2:YesChoice 2 of 2:No

Grading comment:

Explanation:

Save Answer

Q4

10 PointsGrading comment:

Q5.3

2 PointsGrading comment:

System.out.println( (iVar1/iVar2) > (iVar2%iVar1) );

Save Answer

Q5.4

2 PointsGrading comment:

System.out.println( s2.length() + s1 + dVar2 );

Save Answer

Q5.5

2 PointsGrading comment:

System.out.println( (int) (dVar2 / s1.length()) );

Save Answer

Q5.6

2 PointsGrading comment:

System.out.println( s2 + " is " + iVar2 * dVar2 );

Save Answer

Q6

12 PointsGrading comment:

Examine the following code snippets:

import java.util.Random; // Other code... Random rGen = new Random (); boolean b1 = rGen.nextBoolean (); // Could be either true OR false int int1 = 5, int2 = 10; String s = "amenable";

Indicate the whether the indicated lines execute or not:

Line #01: if ((int2 <= int1) && b1) Line #02: System.out.println("a"); Line #03: else Line #04: System.out.println("b"); Line #05: if (b1 || (int1 * int2 >= s.length())) Line #06: System.out.println("c"); Line #07: Line #08: switch ((int) Math.pow(int2, int1) / --int1) { Line #09: case 10000: Line #10: System.out.println("d"); Line #11: break; Line #12: case 25000: Line #13: System.out.println("e"); Line #14: break; Line #15: case 50000: Line #16: System.out.println("f"); Line #17: break; Line #18: }

Answer at least 5 of the following 6 correctly, indicating whether or not the specified line will execute:

Q6.1

2 PointsGrading comment:

Line #02:

Choice 1 of 2:YesChoice 2 of 2:No

Save Answer

Q6.2

2 PointsGrading comment:

Line #04:

Choice 1 of 2:YesChoice 2 of 2:No

Save Answer

Q6.3

2 PointsGrading comment:

Line #06:

Choice 1 of 2:YesChoice 2 of 2:No

Save Answer

Q6.4

2 PointsGrading comment:

Line #10:

Choice 1 of 2:YesChoice 2 of 2:No

Save Answer

Q6.5

2 PointsGrading comment:

Line #13:

Choice 1 of 2:YesChoice 2 of 2:No

Save Answer

Q6.6

2 PointsGrading comment:

Line #16:

Choice 1 of 2:YesChoice 2 of 2:No

Save Answer

Q7

10 PointsGrading comment:

Loops:

Examine the following code:

for (int i = 5; i >= 1; i--) { System.out.print("<<"); for (int j = 5; j >= 1; j--) System.out.print((i * j) % 2 == 0 ? "-" : "*"); System.out.println(">>"); }

Q7.1

4 PointsGrading comment:

Illustrate what would print:

Save Answer

Q7.2

3 PointsGrading comment:

Which lines of output have no dash characters?

Save Answer

Q7.3

3 PointsGrading comment:

Why is this the case?

Save Answer

Q8

10 PointsGrading comment:

Arrays:

For each part, write the line(s) of code required to achieve the specified tasks...

Q8.1

2 PointsGrading comment:

Declare and initialize a String array (call it "names") of size 4:

Save Answer

Q8.2

2 PointsGrading comment:

Declare and initialize another String array (call it "greetings"), which will contain the predetermined values "hey", "hello", "howdy", and "greetings".

Save Answer

Q8.3

3 PointsGrading comment:

Fill names array with strings for any people's names you like.

Save Answer

Q8.4

3 PointsGrading comment:

Write a loop that will print a greeting from greetings followed by a comma and space, followed by the corresponding name (i.e., matching indices in the arrays) from names (on a separate line for each greeting/name pair).

For example: hello, Tracy

Save Answer

Q9

10 PointsGrading comment:

Spot and correct at least five errors in the following program. Start at the very beginning and move forward, looking for errors and assuming that your previous corrections apply, at that point.

Line #01: import java.util.random; Line #02: Line #03: public class 1stFloatClass { Line #04: Line #05: public static void main(String[] args) { Line #06: Line #07: Scanner scan = new Scanner(System.in); Line #08: double[] doubles = new double(); Line #09: int x = 0.0; Line #10: Line #11: for (i = 0; i < doubles.length(); i++) { Line #12: doubles[i] = I * 1.7; Line #13: System.out.print("Enter an int value: "); Line #14: x = scan.next(); Line #15: System.out.println("You entered: " + x); Line #16: System.out.println("Computer says: " + doubles{i} + x; Line #17: } Line #18: Line #19: }

Q9.1

2 PointsGrading comment:

Error #01:

Save Answer

Q9.2

2 PointsGrading comment:

Error #02:

Save Answer

Q9.3

2 PointsGrading comment:

Error #03:

Save Answer

Q9.4

2 PointsGrading comment:

Error #04:

Save Answer

Q9.5

2 PointsGrading comment:

Error #05:

Save Answer

Q10

10 PointsGrading comment:

Write a program that will...

Ask the user for the number of lines,

Store that value in the variable "lines" (already done for you!),

And print out each line.

To print a single line, you should do the following:

Repeatedly print a random character to the line. To do this, you can call the randChar() method. The number of characters printed should be equal to half of the line number. (Notice, in the case of line number 1, that no characters are printed. This is because integer division of 1 by 2 yields a result of zero.)

Skip to the next line.

As you might be able to tell, this is a "nested loop" problem!

NOTE: Remember the distinction between "print" vs. "println"

import java.util.Scanner; public class PrintingChars{ public static void main (String[] args) { Scanner scan = new Scanner(System.in); System.out.println("How many lines?"); int lines = scan.nextInt(); // For each line, between one and the // value of "lines" // Print out a number of characters // equal to one half the line # // Skip to the next line. 

Grading comment:

 } // You can call this method to get a random character private static char randChar(){ java.util.Random rGen = new java.util.Random(); return (char) (rGen.nextBoolean() ? randomIntInRange('a', 'z') : randomIntInRange('0', '9')); } private static int randomIntInRange(int low, int high) { int multiplier = high - (low - 1); return (int)(Math.random() * multiplier) + low; } }

Sample output:

How many lines? 20 Line 1: Line 2: i Line 3: w Line 4: f6 Line 5: ao Line 6: pp1 Line 7: 1e9 Line 8: 1t84 Line 9: 870m Line 10: hjc7w Line 11: a76e2 Line 12: 4c51wu Line 13: 05225s Line 14: 3g6z0y5 Line 15: b4bl4c8 Line 16: d752z92g Line 17: 7m13io15 Line 18: 52i893als Line 19: 50ieiw608 Line 20: wya52mi9jo

Save Answer

Save All Answers

PLEASE HELP ASAP. All answers should go were it says" save answer". Thank you.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Working with other project stakeholders for support.

Answered: 1 week ago