0% found this document useful (0 votes)
67 views

CSCI 201 - Assignment 3

This document provides instructions for Assignment 3 in CSCI 201: Intro to Programming (Java) class. It details the due date as February 21st with a 10 point penalty for submissions within the next 24 hours. It emphasizes that all work must be individual. The assignment involves 3 coding problems - 1) a menu-driven arithmetic calculator, 2) a circle measurement program that outputs diameter, circumference and area given a radius, and 3) a quadratic equation solver that handles different cases based on the discriminant.

Uploaded by

Victor Davis
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

CSCI 201 - Assignment 3

This document provides instructions for Assignment 3 in CSCI 201: Intro to Programming (Java) class. It details the due date as February 21st with a 10 point penalty for submissions within the next 24 hours. It emphasizes that all work must be individual. The assignment involves 3 coding problems - 1) a menu-driven arithmetic calculator, 2) a circle measurement program that outputs diameter, circumference and area given a radius, and 3) a quadratic equation solver that handles different cases based on the discriminant.

Uploaded by

Victor Davis
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CSCI 201: Intro to Programming (Java)

Assignment 3, Due: Friday, February 21st


Due Date
Submit in D2L before 10am on February 21st. You may take an extra 24 hours for a 10-point penalty. No assignments will be accepted after 10am on February 22nd.

Work Alone
It is important that all work you submit for this assignment (and all assignments in this class) be your own. You may talk to other students about the assignment, but you may not exchange code. All code written for this assignment must originate from your brain and your fingertips. You may not copy code from any other source (including the Internet). Please see me if you have questions!

Coding Standards
Be sure to follow the class coding standards (available in D2L) for this assignment! 1. Display a menu that asks the user if he/she wants to add, subtract, multiply, or divide, and get the users choice. You have a few options for doing this. You can list all the options to the user with a number by each option and have the user input the number of the option he/she would like. Alternatively, you could have the user enter the operator (+, -, *, or /) or keyword of the operator (add, subtract, multiply, or divide) he/she wants to perform. Either method is acceptable as long as it is clear to the user what you are asking. If the user enters a valid operator, have the user enter two decimal numbers. Perform the users selected arithmetic operation and output the result. This problem is similar to the first problem of the last assignment, except that instead of performing all arithmetic operations, we are only performing the one the user requests. If the user did not enter a valid operator in the beginning of the program, tell the user that the operator was invalid. In that case, do NOT proceed with asking the user for two numbers.

2. Write a Java program that asks the user to enter a radius of a circle. A decimal number is acceptable for the radius, but it needs to be positive. Once you have obtained a valid radius from the user, output the following 3 lines to the screen: the circle diameter (2 * radius), circle circumference (2 * pi * radius), and circle area (pi * radius * radius). If the user enters 0 or a negative number for the radius, tell the user the radius is invalid. Be sure to use Math.PI to get an accurate value of pi.

3. Write a Java program that asks a user to enter the coefficients a, b, and c. Use the coefficients to solve the quadratic formula for x. The coefficients can be decimal numbers. The only restriction is that a must not be zero. Quadratic Formula:

The discriminant is the name of the term under the root sign in the quadratic formula (b * b 4 * a * c). If the discriminant is negative, there are no real solutions for x. In this case, tell the user there are no real solutions. If the discriminant is 0, there will be one real solution for x. In this case tell the user there is one solution and display the value of x. If the discriminant is positive, there will be two solutions for x. In this case tell the user there are two solutions and display both values of x. Note: This is one of the rare situations where is it OK to name your variables a, b, and c. In most instances these would not be acceptable variables names, but in this case, those letters actually do accurately describe the purpose of the variables.

You might also like