Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how can i solve it  RSS feed

 
Manal Ahmad
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
GUI, Recursion and Exception Handling
Problem Statement
A simple calculator has function keys for adding, subtracting, multiplying and dividing two numbers. It also has a function key for calculating the factorial of an integer.
Requirements: (10 marks)
Using the Keypad class, write a program to simulate a simple calculator.
(1)Add 6 more buttons for add, subtract, multiply, divide, equal and factorial functionalities to the keypad GUI.
(2)Implement the factorial function. The factorial must be applied to an integer.
(3)Throw an exception if the number entered has the wrong format. For example, the number 25.5.3 has the wrong format.
The GUI of your program should look like this:

Bonus: (5 marks)
(1) Implement the calculator functions for adding, subtracting, multiplying and dividing.
(2) Throw an exception if the user attempts to divide a number by zero.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't how we do things here - people will not normally provide you with answers to assignment questions. Show us what you have written so far, or ask us about something more specific you are stuck on. You are more likely to get help that way.
 
Nigel Browne
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me guess this is URGENT :roll:
 
Dilip Fernandez
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the "Keypad" class? Not part of the Java API.
If you need a program to simulate a calculator, there's one in Horstmann and Cornell's "Core Java Vol I - Fundamentals" in the chapter on Applets. ISBN 0130819336.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!