Answer to Question #230636 in Java | JSP | JSF for Wayos

Question #230636

Flow control is one of the main building blocks that determines how a program should run. Ghana Cocoa Growing company wishes to compare the impart of two newly acquired fertilizers on cocoa. They will do this by applying the same quantity of the two fertilizers on two similar but different cocoa plant under the same conditions (humidity, sunlight, soil moisture etc.). They will then choose the fertilizer whose crop produces the best harvest (highest quantity per square feet). As a programmer, 

 

a. Suggest a flow control method that would be used to do the comparison and explain the reason why you chose it.   

b. Write a flow control statement that would do the comparison in “a” above. 



1
Expert's answer
2021-08-29T00:57:21-0400

a.

Using decision making statements. It will compare the fertilizer with the best harvest.

b.

import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    Scanner in =new Scanner(System.in);
		int f1 ;   
        int f2 ;  
        System.out.println("Enter highest quantity per square feet of the first fertilizer:");
        f1=in.nextInt();
        System.out.println("Enter highest quantity per square feet of the second fertilizer:");
        f2=in.nextInt();
        if(f1>f2) {  
            System.out.println("The first fertilizer is the best");  
        }   
        else {  
            System.out.println("The second fertilizer is the best");  
        }  
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS