/* File: week2_5a * Author: Matt Faulkner * Date: 4 June 07 * Class: CMIS 141 * Instructor: Dr. Yuan * Problem: 2.33, pg 97, Java 5.0 Programming Guide * Purpose: Evaluate 3x^4 - 10x^3 + 13 * Status: Ready * Notes: Exception handling needs to be added * History: * 4 Jun 07 - Start/End * */ import java.util.*; public class week2_5a { public static void main (String[] args) { //Set up input stream Scanner stdin = new Scanner(System.in); //Legend System.out.print("The program will evaluate the expression "); System.out.println("3x^4 - 10x^3 + 13\n\n"); //Receive input for value x in equation System.out.print("Enter a floating point number: "); float x = stdin.nextFloat(); //x is the input value from the user //Calculates x to the third power double toTheThird = Math.pow (x, 3); //Calculates x to the fourth power double toTheFourth = Math.pow (x, 4); double answer = (3 * toTheFourth) - (10 * toTheThird) + 13; System.out.print("Based on your input of " + x + ", the value of"); System.out.println ("3x^4 - 10x^3 + 13 = " + answer + ".\n\n\n"); } // end method main } // end class week2_5