### [solution] » 1.(a)Write a Java program that displays the value of (a + b) + c and a + (b + c), where a is a fl

Description

The Question

1.(a)Write a Java program that displays the value of (a + b) + c and a + (b + c), where a is a float variable, b is the negation of a, and c is 1.0.

(b) Using this program, determine the smallest positive integer n such that assigning a the value 10n causes the expressions (a + b) + c and a + (b + c) to have different values. Your answer should include your program?s source code and the output that it produces when executed.

2. Write a single (non-nested) Java statement that displays the following message: "Your shopping cart contains 5 items" Assuming that variable n contains the number of items. If n has the value 1, the statement should display the following message instead: "Your shopping cart contains 1 item" You may not use the if statement or switch statement. Your statement must consist of a single call of System.out.println. Simplify your answer as much as possible.

3. Assume that the C array a has been declared as follows:

int a[N][N];

The following loop initializes the elements of a:

for (int i = 0; i < N; i++)

for (int j = 0; j < N; j++)

a[i][j] = i * N + j;

Rewrite this loop so that (a) it uses a single for statement and (b) it uses a pointer, not two integers, to keep track of which array element is the next to be initialized. The only variable that should appear in your code (other than a itself) is the pointer variable

#### Solution details

Solution #00020358

##### [solution] » 1.(a)Write a Java program that displays the value of (a + b) + c and a + (b + c), where a is a fl.zip

This paper was answered on 14-Oct-2020

STATUS

QUALITY

Approved

Oct 14, 2020

EXPERT

Tutor

#### BEST TUTORS

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

• As a reference for in-depth understanding of the subject.
• As a source of ideas / reasoning for your own research (if properly referenced)
• For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student. 