Write a java program that solves the problem for the farmers

Assignment Help JAVA Programming
Reference no: EM131192187

Topics:

• Entering, compiling, and running a Java program.
• Using arithmetic expression & casting
• Using Scanner class for input

Important Note: All submitted assignments must begin with the descriptive comment block similar to the one shown below under Part 1, Program #1. It must contain your name and the other information illustrated. To avoid losing trivial points, make sure this comment header is included in every assignment you submit, and that it is updated accordingly from assignment to assignment.

Part 1: Program #1 Compile and Run:

Type the following code into a file called Expressions.java. After the program is entered, compile and run the application to make sure it works. Each invocation of println outputs an arithmetic expression. The first two println commands are followed by comments that describe the operations that occur in each expression. Complete the program by adding a comment after each println statement that describes all the arithmetic operations that occur when evaluating the expression that is printed.

//***********************************************************
// Name: Faye Navabi
// Title: Expressions.java
// Author: Modified from an example in Big Java book
// Description: arithmetic operations in Java
// Time spent: 30 minutes
// Date: 8/15/2016
//************************************************************** public class Expressions
{
public static void main(String[] args)
{
int a = 3; int b = 4; int c = 5; int d = 17;
System.out.println((a + b)/ c);
// a) 3 and 4 are added with sum 7
// 7 is divided by 5 with quotient 1 System.out.println(a + b / c);
// b) 4 is divided by 5 with quotient 0
// 3 is added to 0 with sum 3 System.out.println(a++);//c) System.out.println(a--);//d) System.out.println(a + 1);//e) System.out.println(d % c);//f)
System.out.println(d / c);//g) System.out.println(d + a / d + b);//h) System.out.println((d + a) / (d + b));//i) System.out.println(Math.sqrt(b));//j) System.out.println(Math.pow(a, b));//k)
}
}

Note: The answers to each System.out.println (a through k) above should be typed in the block of comments in the Assignemnt1.java file. Do NOT submit this file only the answers are typed as block of comments in the file(Assignment1.java). Answers to a and b are provided in the code above.

Program #2: Programming

Overview: Write a complete Java program in a source file to be named Assignment1.java, that solves the problem for the farmers who are trying to decide ahead of time how many completely filled jars they need. For example if the farmer has 5 1/2 gallons of milk and wants to store them in milk jars that can hold up to 0.75 gallons each will need 7 jars.

Your program asks farmer for the gallons of milk and computes the number of jars needed by each farmer for that purpose.

Note: Make sure to use constants to improve legibility and make it easier to maintain. Example Execution: Below is a sample execution. Bold text indicates user input. How many gallons of milk? 5.5
You need 7 jars for 5.5 gallons of milk.

Implementation Details:

• You can assume that the user will always input a positive integer for gallons of milk. The user may enter zero but not negative numbers.
• You may want to create variables for the following pieces of information:

? Gallons of milk (double)
? Completely filled jars (int)

• You may use additional variables if you desire, and you are not required to create the ones mentioned above.
• This program should be implemented using only one class (called Assignment1) and should only contain one method (main).

Additional Sample Output:

Sample 1:

How many gallons of milk? 5
You need 6 jars for 5.0 gallons of milk. Sample 2:
How many gallons of milk? 6.8

You need 9 jars for 6.8 gallons of milk.

For this and all subsequent assignments, provide a heading (in comments) described above and demonstrated in Program #1. Make sure your program is called Assignment1.java

Submit your homework by following the instructions below:

• Go to the course web site (my.asu.edu), and then click on the on-line Submission tab. Fill out the registration form before submitting your assignment. Make sure you use the correct email address for registration. This will allow you to submit assignments. Please use your ASU e-mail address.

• Submit your Assignment1.java file on-line. Make sure to choose Hw1 from drop-down box.

• Assignment1.java should have the following, in order:

o In comments, the assignment Header described in "Important Note" and demonstrated in Program #1.
o In comments, the answers to questions a-k presented in Program #1. Do NOT submit the code given in Program #1.
o The working Java code requested in Program #2.
o The Assignment1.java file must compile and run as you submit it. You can confirm this by viewing your submission results.

Important Note: You may resubmit as many times as you like until the deadline, but we will only mark your last submission.

Reference no: EM131192187

Questions Cloud

Program to add three values to the end of the array : Write a program in Java that reads integers into an array list until end-of-file, then prints the array. Then Modify the program to add three 99 values to the end of the array.
Write a program in java that reads integers : Part 1: Write a program in Java that reads integers into an array list until end-of-file, then prints the array. Part 2: Modify the program to insert the value 99 before the index 5 position.
What would you describe as j and js primary concern : What would you describe as J&J's primary concern related to the proposed guidance?-  From what perspective are they raising this concern?
Next major phase in software development life cycle : The next major phase in software development life cycle (SDLC) is testing. Quality assurance methods and testing help support this phase. Investigate the library and Internet for information on the various tests that should be performed at differen..
Write a java program that solves the problem for the farmers : Write a complete Java program in a source file to be named Assignment1.java, that solves the problem for the farmers who are trying to decide ahead of time how many completely filled jars they need.
Total number of clock cycles : a) The clock rate for this machine is b) The total number of clock cycles consumed by the entire program is c) What speedup (expressed to two decimal places) would be obtained for this program by making the divide instructions twice as fast? Speedu..
Calculating the codewords for all possible combinations : Using the CRC generator G, construct a code table by calculating the codewords for all possible combinations of the 3-bit dataword, respectively. The code table defines an (n, k) CRC code. Determine the values of n and k respectively and explain t..
Types of data transmission methods : Using examples and providing application areas of each, describe the two types of data transmission methods
Types of data transmission methods : Using examples and providing application areas of each, describe the two types of data transmission methods?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Program (using java) that is suppose to find the largest

writing a program (using java) that is suppose to find the lowest integer that can be evenly divided by a range (ex. 1-25). I need help fixing/debugging it so it comes up with the proper output.

  Develop a java application for the local library

Develop a Java application for the local library as part of an upgrade initiative. As in all libraries, this is a place where one can check out books.

  Write a program that starts a player off with a bank of $15

Write a program that starts a player off with a bank of $15.00.

  What is abstract class and how it differ from regular class

What is an abstract class and how does it differ from a regular class? Why are abstract class constructors defined as protected

  How to count number of objects (instances) created

How to count number of objects (instances) Created, use java code and please be descriptive

  Create floating point arrays

Create floating point arrays each with three elements - Ask the user to give input for the two arrays.

  Create a class with a method that accepts a charge card acnt

Create a class with a method that accepts a charge card account number as its argument. The method should determine whether the number is valid by comparing it with a list of valid charge card account numbers

  Java code using jframe

Write a Java code using JFrame. This code needs to manipulate 4 shapes(2 rectangles and 2 squares) in a 400x400 JFrame. This needs to manipulate the shapes in 3 different ways, using 3 different methods. One for translating a shape, one for proportio..

  Modify the java application using java netbeans and ide

Modify the Java application using Java NetBeans IDE to meet these additional and changed business requirements: The company has recently changed its total annual compensation policy to improve sales.

  Explain polymorphism

Explain polymorphism. Do all programming languages have polymorphism, and why or why not? Why is it useful and identify situations where polymorphic behavior would be absolutely necessary

  Develop a similar class hierarchy for pets.

Java programmers can use class hierarchies for the purposes of inheritance. For example, given a Tree class, we could define Conifer and Deciduous sub classes that inherit from the parent Tree class as you can see here:

  Class that stores information about a report

Create a class that stores information about a report containing multiple currency transactions in multiple currencies. This includes the name of the report and each of the transactions that occurred.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd