Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment 9.3: Fruit Codes - Redux (10 pts) 70% of the produce sold in the U.S. contains pesticide residues [1]. One large study published in
Assignment 9.3: Fruit Codes - Redux (10 pts)
- 70% of the produce sold in the U.S. contains pesticide residues [1].
- One large study published in the respected medical journal JAMA, found that people who consumed the most organic foods had 25% fewer cancers than those who ate no organic food [2].
- Additionally, foods that are genetically modified tend to be sprayed with large amounts of weed killers [3].
- Regardless of these concerns, most nutrition experts agree that eating fruits and vegetables - either conventional or organic - in large quantities is one of the most important things you can do for your health [4]
- Write a program to read in the code printed the sticker on a piece of fruit and print out whether the fruit was grown organically, or conventionally or was genetically modified.
- The program should prompt the user to enter the numeric code on the fruit's sticker, and then read in the user's response as a String.
- Codes that are 4 digits long indicate that the fruit has been grown conventionally.
- In this case, print the message: "Your fruit was grown conventionally, with the use of pesticides and chemicals."
- Codes that are 5 digits long, and start with an 8, indicate that the fruit has been genetically modified.
- In this case, print the message: "Your fruit was genetically modified."
- Codes that are 5 digits long, and start with a 9, indicate that the fruit was grown organically.
- In this case, print the message: "Your fruit was not genetically modified, and was grown according USDA organic standards."
- Codes that do not follow the above format are considered invalid.
- Name your file Fruit.java.
- The program should work identically to the sample output below.
- Additionally, your code should use exactly one if, two else ifs and one else.
- For full credit, you must use the String methods covered in class in your solution to this assignment.
Sample Output:
Enter the fruit code: 96544 Your fruit was not genetically modified, and was grown according USDA organic standards.
Sample Output:
Enter the fruit code: 8455 Your fruit was grown conventionally, with the use of pesticides and chemicals.
Sample Output:
Enter the fruit code: 84556
Your fruit was genetically modified.
Sample Output:
Enter the fruit code: 123
Invalid code. Please try again.
Sample Output:
Enter the fruit code: 12345678
Invalid code. Please try again.
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