Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 2 Meadowdale Dairy Farms sells organic eggs to local customers. They charge $3.25 for a dozen eggs, or 45 cents for individual eggs that

QUESTION 2

  1. Meadowdale Dairy Farms sells organic eggs to local customers. They charge $3.25 for

a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a program that prompts user for the number of eggs in the order and then display the amount owed with a full explanation. For example, typical output might be, You ordered 27 eggs. Thats 2 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $7.85. Use a sequence program structure.

  1. Using a while loop, write a program to calculate the sum of variable num from integers

3 to 13.

(7 marks)

  1. Identify the lines of code that has error and explain what is wrong. (4 marks)

1 public class Loop {

2 public void main(String[] args) {

3 for (int m = 0; m < 10; m++);

4 sum += m;

5

6 if (m < n);

7 System.out.println(m)

8 else

9 System.out.println(n);

10

11 while (n < 10);

12 {

13 n++;

14 }

15

16 do {

17 n++;

18 } while (n < 10)

19 }

20 }

  1. Use Microsoft Word / MS Visio to draw a flowchart for the following. (5 marks)
  1. Enter www Facebook com in your browser.
  2. Facebook Home page loads.
  3. Enter your Email ID and Password.
  4. Is Email ID and Password Valid. if NO then Log in error go to step 3 else Display Facebook Account Stop

  1. Write a if..else segment code for the following.

It said that if the gender of a person is woman and above 40 year of age and if she is either overweight, smokes or has family history of cancer then her chances of having cancer is higher. Therefore, she has to get a medical check-up done. (6 marks)

  1. State whether each of the following is true or false. If false, explain why. (2 marks)
    1. The default case is required in the switch selection statement.

  1. The break statement is required in the last case of a switch selection statement.

  1. Indicate the output that will be produced by question (f) (i) and (f) (ii) if the following variables are declared :

final int START = 15, END = 25;

int num = 20;

  1. do

{

num = num + 1;

System.out.println (num);

}

while (num <= END);

(3 marks)

  1. while (num >= START)

{

System.out.println (num);

num = num 1}; }

(3 marks)

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_2

Step: 3

blur-text-image_3

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

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions

Question

17. As new data becomes available, repeat steps 11 through 16.

Answered: 1 week ago

Question

16. Implement this MPEMP.

Answered: 1 week ago