Question
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
- 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.
- Using a while loop, write a program to calculate the sum of variable num from integers
3 to 13.
(7 marks)
- 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 }
- Use Microsoft Word / MS Visio to draw a flowchart for the following. (5 marks)
- Enter www Facebook com in your browser.
- Facebook Home page loads.
- Enter your Email ID and Password.
- Is Email ID and Password Valid. if NO then Log in error go to step 3 else Display Facebook Account Stop
- 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)
- State whether each of the following is true or false. If false, explain why. (2 marks)
- The default case is required in the switch selection statement.
- The break statement is required in the last case of a switch selection statement.
- 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;
- do
{
num = num + 1;
System.out.println (num);
}
while (num <= END);
(3 marks)
- 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started