Can you help me figure out how to correctly make a prompt that fits these paramaters?

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter12: Exception Handling
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question

Can you help me figure out how to correctly make a prompt that fits these paramaters?

d. increase() which prompts the user to change the value stored in the object. It
repeatedly re-prompts the user until they enter a numeric value larger than the
value currently stored in the object, at which point the method resets the value of
the object to the number obtained from the user. The method must recover from
illegal input of all types, and several examples are shown below. It does not return
any values.
ving shows how the Salary class and its methods could be used:
>>> s1 = Salary()
>>> s1
Salary(31200)
>>>print(s1)
$31200.00
>>> s1.increase()
The current salary is $31200.00.
Enter a new value (>
31200): 31199.99
The value must be larger than the
existing salary.
The current salary is $31200.00.
Enter a new value (> 31200): forty
thousand
Please enter a numeric value using
digits.
The current salary is $31200.00.
Enter a new value (>
31200): 32500.55
>>> s1
Salary(32500.55)
>>>print(s1)
$32500.55
>>> $2=Salary(0)
>>> S2
Please enter a numeric value using
digits.
The current salary is $31200.00.
Enter a new value (>
31200): [3333]
Please enter a numeric value using
digits.
The current salary is $31200.00.
Enter a new value (> 31200): 33300
>>> $2
Salary(33300)
>>>print(s2)
$33300.00
>>> s3 = Salary(17000.8)
>>> $3
Salary(17000.8)
>>>print(53)
$17000.80
>>> s4 = Salary('fifteen thousand')
>>> $4
Salary(31200)
>>> $5 = Salary([33333])
>>> $5
Salary(31200)
>>> s6 = Salary(Measure(5))
Transcribed Image Text:d. increase() which prompts the user to change the value stored in the object. It repeatedly re-prompts the user until they enter a numeric value larger than the value currently stored in the object, at which point the method resets the value of the object to the number obtained from the user. The method must recover from illegal input of all types, and several examples are shown below. It does not return any values. ving shows how the Salary class and its methods could be used: >>> s1 = Salary() >>> s1 Salary(31200) >>>print(s1) $31200.00 >>> s1.increase() The current salary is $31200.00. Enter a new value (> 31200): 31199.99 The value must be larger than the existing salary. The current salary is $31200.00. Enter a new value (> 31200): forty thousand Please enter a numeric value using digits. The current salary is $31200.00. Enter a new value (> 31200): 32500.55 >>> s1 Salary(32500.55) >>>print(s1) $32500.55 >>> $2=Salary(0) >>> S2 Please enter a numeric value using digits. The current salary is $31200.00. Enter a new value (> 31200): [3333] Please enter a numeric value using digits. The current salary is $31200.00. Enter a new value (> 31200): 33300 >>> $2 Salary(33300) >>>print(s2) $33300.00 >>> s3 = Salary(17000.8) >>> $3 Salary(17000.8) >>>print(53) $17000.80 >>> s4 = Salary('fifteen thousand') >>> $4 Salary(31200) >>> $5 = Salary([33333]) >>> $5 Salary(31200) >>> s6 = Salary(Measure(5))
#Do not add any parameters
def
init (self, amount = 31200) :
'Initalizaing balance of salary'
self.bal amount
def
pass
def repr (self):
return f"Salary {self.bal}"
pass
str (self):
'returns string containg the current value stored in object in 2 decimal
return "$" + str (round (self.bal, 2))
pass
def increase (self):
increase = int (input ("The current salary is" + (self.bal) + "Enter a new
pass
Transcribed Image Text:#Do not add any parameters def init (self, amount = 31200) : 'Initalizaing balance of salary' self.bal amount def pass def repr (self): return f"Salary {self.bal}" pass str (self): 'returns string containg the current value stored in object in 2 decimal return "$" + str (round (self.bal, 2)) pass def increase (self): increase = int (input ("The current salary is" + (self.bal) + "Enter a new pass
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT