Tags:
tag this topic
create new tag
view all tags
---+Repetition Lab: Calculator: Fall 2024 ---++ Learning Objective(s) * Enhance skills with constants * Learn about event controlled loops (and use a priming read) * Learn to use a switch statement * Work with floating point, characters and string data types * Statement coverage for testing * Enhance overall programming skills ---++ Overview of the Program Write a program to simulate a simple calculator working with floating point arithmetic (+, -, *, /). ---++ Specifics * The program is to be called <b>Calculator</b> * It is to allow for floating point arithmetic (<b>double is probably best</b>) * There should be at least 5 characters constants (one for each operation and for the ending signal) * <b>!</b> is used to signal the end of the input * After each operation, the current result should be displayed * If an invalid operation is inputted, the user should be informed and then allowed to re-enter * A priming read must be used ---++ Sample dialogue Below is a sample dialogue. The prompts may vary but the input given by the user is to be the same format. Your output can vary somewhat as long as the required data is nicely displayed.<br> <pre> What is the first number? <b><font color="blue">5</font></b> What operation (+, -, *, /, or ! to end)? <b><font color="blue">+</font></b> What is your next number? <b><font color="blue">7</font></b> 12.0 Next operation? <b><font color="blue">t</font></b> That is an invalid option. Please re-enter. Next operation? <b><font color="blue">-</font></b> What is your next number? <b><font color="blue">2.5</font></b> 9.5 Next operation? <b><font color="blue">!</font></b> </pre> You can also run a solution for this program if you want. See classroom instructions for more details. ---++Lab Hints * Hint 1: [[%ATTACHURL%/CalculatorFC.pdf][a flowchart that you can use]] * Hint 2: See class examples for priming reads * Hint 3: [[CSC121F2024Lab03Hint03][common mistakes for a switch statement]] * Hint 4: [[CSC121F2024Lab03Hint04][Going from strings to characters]] ---++ Submission * Create a software development report * For the system design, you may use my flowchart if it is the design of your program. Otherwise, you need to make your own. * For testing report, * make sure your tests ensure that each statement is executed at least one. * your <b>expected output</b> <font color="red">CANNOT</font> be pasted from the dialogue of a running. Only the actual output may be pasted * It should contain two different inputs that are "errors" * For the improvement section, specify how many points were lost from the last lab that you should not lose points for on this lab because you corrected the problem * create a pdf document from your software development report * create an empty zip folder * place *only* !Calculator.java and your pdf document into it * submit the zip folder on canvas ---++ Optional improvements Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor. 1. Add an option to clear the current result (specified by a <b>C</b>) 1. Add another arithmetic operation 1. Allow the user to use different number bases (such as binary, octal, hex) 1. Add the use of memory. 1. Combine any and all optional improvements into one program (called <b>CalculatorExtra.java</b>) and add it to the zip folder before submitting it
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r2 - 2024-09-04
-
CathyBareiss
Home
Site map
Assessment web
BethelAIResources2026 web
CenterForComputing web
ChatGPT web
Intro2AIatBethel web
Main web
Sandbox web
TWiki web
CenterForComputing Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
P
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback