java代写 | 网络传输

Java代写/NetBeans/Java GUI/Java Basic

JAVA窗体程序,根据用户输入返回不同的结果处理

CP 1 PA2

See Blackboard calendar for due dates.

You may re-use what you started on Programming Assignment1 for this assignment.

The Assignment Description follows the Self-Grade Sheet.

Grading Criteria:

Please submit all of the following to the Assignments tab in NetBeans.  Compress ALL of the following items into one zip file and submit it.

  • This completed grade sheet.
  • Complete the grading sheet below. Enter the number of points you believe you have earned out of 10.  Give yourself more than five if you put forth some effort.  Give yourself five points if you did not attempt the item.  If you assign more than five points, but you did not attempt the item, I will change the grade to 0 points.

Self-Grade Sheet

Overall:

Did something extra, something beyond the minimum requirements stated here: 10 _____  Specifically, what did you do? _______________________________________________

Commented with proper JavaDoc style comments above every method, and inline comments, where appropriate: 10 _____

Assignment 3:

All requirements from PA 1 Part 2 are met: 10___

 

Calculations are correct and datatypes are converted properly: 10 _____

 

The program uses an if test, and takes appropriate action to determine whether a user entered a C or an F.  If the user enters C, setCelsius is invoked.  If the user enters F, setFahrenheit is invoked: 10 _____

The program uses a while loop to re-prompt the user if the user does not enter a C or an F: 10 _____

After inputting, converting, and printing data, the program uses a do-while loop to ask the user if he/she would like to perform another conversion.  This loop is separate from the C or F validation: 10 _____

The program uses an if test, comparing input to null, to determine whether or not the user entered a value for temperature: 10 _____

Method setCelsius in class Converter converts the parameter variable to Fahrenheit, and stores that value in the one attribute of class Converter.   There is only one attribute in class Converter. 10___

Output is correct, and in good form.  getFahrenheit and getCelsius are invoked on every iteration: 10 ____

 

Additional Deductions:

Code not in good form (sloppy, bad spelling, etc.): up to -10
Late: -10% at the beginning each 24 hour period, starting promptly at 6:30 PM on the due date.
Copying someone else’s work: F for the entire quarter.
NO credit will be given for assignments more than four days late.

Assignment Description:

From PA1 Part 2, you now have a user interface class named ConverterRunner, and a Plain Old Java Object, or JavaBean class named Converter.  We’ll add Celsius input to these classes.

 

 

  • Add a method to class Converter named setCelsius. This method should accept a double, and convert the incoming temperature to Fahrenheit.  It should then store that value in the fahrenheit attribute of your temperature object.
    1. The formula to convert Celsius to Fahrenheit is:

Fahrenheit = (1.8* Celsius)+32.

 

In this formula, Celsius should be the parameter variable from the method, and Fahrenheit should be the attribute of class Converter.

  • The promptUser method of class ConverterRunner should do the following:
    1. prompt the user for two items: a temperature and a letter, either C or F.    To get this information from the user, you can use the showInputDialog method of the class JOptionPane. You will need an if test to determine whether the user entered C or F.

 

  1. Use a while loop and an if test to validate that the user has entered a C or an F. If the user has not entered a C or an F, prompt the user to enter information again.

 

  1. If the user enters ‘C’, assume the number is a temperature in degrees Celsius. Convert this value to a double, and then pass the value to the setCelsius method of the Converter object.

 

  • If the user enters ‘F’, assume the number is a temperature in degrees Fahrenheit. Using the setFahrenheit method, store that number in the Converter object.

 

  1. If the user does not enter a temperature, allow the program to proceed, and use a default of 35. You will probably need an if test that compares the user’s temperature input to null to do this.

 

  1. The method should have the following outputs, regardless of the temperature type entered:
    1. Invoke getFahrenheit() on your Converter object, and print the result.
    2. Invoke getCelsius() on your Converter object, and print the result.

 

  • After the user has entered temperature and the program has printed output, ask the user if he/she would like to enter another temperature and another C or F. Use a JOptionPane  to prompt the user.  Do not invoke the method recursively (have a method call itself).  Instead, place the logic that you would like to repeat within the loop body.  You can either place this loop in the main method or the promptUser method, but it must be different than the while loop in step 2-a-i.

 

  • Do something extra, something not listed here.

Hint: To convert a String to a double, do this:

String input = 5.0;

double dblInput = new Double(input);