hw08
.py
keyboard_arrow_up
School
University of California, Berkeley *
*We aren’t endorsed by this school
Course
88
Subject
Computer Science
Date
Dec 6, 2023
Type
py
Pages
4
Uploaded by MajorFogLeopard31 on coursehero.com
################
#### OOP #####
################
class Error:
"""
>>> err1 = Error(12, "error.py")
>>> err1.write()
error.py:12
"""
def __init__(self, line, file):
"*** YOUR CODE HERE ***"
self.line = line
self.file = file
def format(self):
return self.file + ':' + str(self.line)
def write(self):
print(self.format())
class SyntaxError(Error):
"""
>>> err1 = SyntaxError(17, "lab10.py")
>>> err1.write()
lab10.py:17 SyntaxError : Invalid syntax
>>> err1.add_code(4, "EOL while scanning string literal")
>>> err2 = SyntaxError(18, "lab10.py", 4)
>>> err2.write()
lab10.py:18 SyntaxError : EOL while scanning string literal
"""
type = 'SyntaxError'
msgs = {0 : "Invalid syntax", 1: "Unmatched parentheses", 2: "Incorrect
indentation", 3: "missing colon"}
def __init__(self, line, file, code=0):
"*** YOUR CODE HERE ***"
super().__init__(line,file)
self.message = self.msgs[code]
def format(self):
"*** YOUR CODE HERE ***"
end = self.type + ' : ' + self.message
return self.file+":"+str(self.line)+" "+end
def add_code(self, code, msg):
"*** YOUR CODE HERE ***"
self.msgs[code]=msg
class ZeroDivisionError(Error):
"""
>>> err1 = ZeroDivisionError(273, "lab10.py")
>>> err1.write()
lab10.py:273 ZeroDivisionError : division by zero
"""
type = 'ZeroDivisionError'
def __init__(self, line, file, message='division by zero'):
"*** YOUR CODE HERE ***"
super().__init__(line,file)
self.message = message
def format(self):
end = self.type + ' : ' + self.message
"*** YOUR CODE HERE ***"
return self.file+":"+str(self.line)+" "+end
# Linked List Class
class Link:
"""
>>> s = Link(1, Link(2, Link(3)))
>>> s
Link(1, Link(2, Link(3)))
"""
empty = ()
def __init__(self, first, rest=empty):
assert rest is Link.empty or isinstance(rest, Link)
self.first = first
self.rest = rest
def __repr__(self):
if self.rest is not Link.empty:
rest_str = ', ' + repr(self.rest)
else:
rest_str = ''
return 'Link({0}{1})'.format(repr(self.first), rest_str)
# Notice that this is not part of the Link class.
def print_link(link):
"""Print elements of a linked list link.
>>> link = Link(1, Link(2, Link(3)))
>>> print_link(link)
<1 2 3>
>>> link1 = Link(1, Link(Link(2), Link(3)))
>>> print_link(link1)
<1 <2> 3>
>>> link1 = Link(3, Link(Link(4), Link(5, Link(6))))
>>> print_link(link1)
<3 <4> 5 6>
"""
print('<' + helper(link).rstrip() + '>')
def helper(link):
if link == Link.empty:
return ''
elif isinstance(link.first, Link):
return '<' + helper(link.first).rstrip() + '> ' + helper(link.rest)
else:
return str(link.first) +' '+
helper(link.rest)
######################
#### Linked Lists ####
######################
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Enter the name of Stock: Oracle Corporation
Enter the symbol of Stock: URCL
Enter the previous closing price: 34.5
Enter the current price: 34.35
Stock name: Oracle Corporation
Stock symbol: ORCL
Stock ID: 59
Price-change percentage: - 0.434782608695648
Challenge Question - Using GregorianCalendar and Date classes:
(Use the GregorianCalendar class) Java API has the Date class and GregorianCalendar class in
the java.util package, which you can use to obtain the current date with specific details like
current year, current month, current day of a date and so on.
Write a program to perform these tasks:
1. Display the current year, month, and day.
2. Display the current date by using the to String() method from the Date class.
3. Display the current time-which is used to display the number of milliseconds- by
using getTime() method from the Date class. We will use it in the step 17.
4. - Display the current year by using get(GregorianCalendar.YEAR) method from to
GregorianCale class.
5-…
arrow_forward
Enter the name of Stock: Oracle Corporation
Enter the symbol of Stock: URCL
Enter the previous closing price: 34.5
Enter the current price: 34.35
Stock name: Oracle Corporation
Stock symbol: ORCL
Stock ID: 59
Price-change percentage: - 0.434782608695648
Challenge Question - Using GregorianCalendar and Date classes:
(Use the GregorianCalendar class) Java API has the Date class and GregorianCalendar class in
the java.util package, which you can use to obtain the current date with specific details like
current year, current month, current day of a date and so on.
Write a program to perform these tasks:
1. Display the current year, month, and day.
2. Display the current date by using the to String() method from the Date class.
3. Display the current time-which is used to display the number of milliseconds- by
using getTime() method from the Date class. We will use it in the step 17.
4. - Display the current year by using get(GregorianCalendar.YEAR) method from to
GregorianCale class.
5-…
arrow_forward
Choose correct option
It is disadvantageous to use public variables in classes because ___________
It results in compilation error
It cannot control its values
It cannot be accessed by other variables
Its values cannot be initialized
arrow_forward
Python Code:
###########################################class MovieNode: def __init__(self, title, year, director, genre): self.title = title self.year = year self.director = director self.genre = genre self.next = None self.prev = None
def __str__(self): return f"Title: {self.title:<25} Year: {self.year:<6} Director: {self.director:<20} Genre: {self.genre:<10}"
def __lt__(self, other): if self.title < other.title: return True else: return False
###########################################class MovieList: def __init__(self): self.head = None self.tail = None
def display(self): curr = self.head while curr: print(curr) curr = curr.next # Append new_movie at end of MovieList def append_movie(self, new_movie): # simply adding book to the end of the ddl if self.head == None: self.head = new_movie…
arrow_forward
Staff
# name: String
# id: int
PartTimer
+ Staff()
+ Staff(name: String,
id: int)
skillLevel: int
+ getName (): String
+ getId (): int
+ calculatePay () : double
+ toString (): String
hoursWorked: int
+ Part Timer (name: String,
id: int,
skillLevel: int,
hoursWorked: int)
+ getskillLevel(): int
+ getHours Worked () : int
+ tostring () : String
java.lang.Comparable
compareTo (o: Object): int
Figure 1: The relationship between staff, PartTimer and Comparable
Skill Level / Tahap Kemahiran
Pay Rate Per Hour/ Kadar Bayaran Per Jam
0 ( Basic / Asas)
RM50.00
1 (Moderate / Sederhana)
RM100.00
RM150.00
2 (Expert / Mahir)
Table 1: Skill level and the pay rate per hour
Write a complete Java program to create PartTimer class and test class based on the Figure 1, Table 1
and the following requirements: Partimer class is derived from staff and implements Comparable
Interface. The calculate Pay()method from the staff class will be implemented in the subclass to
calculate the employee's pay. The pay…
arrow_forward
In Python:
Design a class named AutomobileLoan that holds:
a loan number
make of automobile
model of automobile
balance of loan
Include methods to:
set values for each data field
displays all the loan information
Create the class diagram and write the pseudocode that defines the class.
Design an application using pseudocode that:
declares two AutomobileLoan objects
sets the values of both objects
displays the values of both objects
Deliverables
Class Diagram
Pseudocode that defines the class
Pseudocode that declares, sets, and displays 2 AutomobileLoan objects
arrow_forward
What will this code print?
def fun_a():
print("aa")
def fun_b():
print("bb")
def fun_c():
print("cc")
def main():
fun_c()
fun_a()
fun_b()
fun_c()
Question 13 options:
cc
aa
bb
cc
aa
bb
cc
aa
cc
bb
cc
cc
bb
aa
nothing
arrow_forward
ga Class in Python
Creating a Class in Python
MyRectangleClassPro.
Rectangle.py
1 # This program uses the programmer-defined Rectangle class.
2
Summary
3 # Do NOT modify this program. Write your code in Rectangle.py,
4 # then select this file and click "Run Code".
In this lab, you create a programmer-defined class and then use it in a Python program. The
5
program should create two Rectangle objects and find their area and perimeter.
6 from Rectangle import Rectangle
7
8 rectanglel = Rectangle(10.0, 5.0)
9 rectangle2 = Rectangle(7.0, 3.0)
Instructions
10
1. Open the class file named Rectangle.py
11 print("Perimeter of rectanglel is " + str(rectanglel.calculatePerimeter()))
12 print("Area of rectanglel is " + str(rectanglel.calculateArea()))
13 print("Perimeter of rectangle2 is " + str(rectangle2.calculatePerimeter()))
14 print("Area of rectangle2 is " + str(rectangle2.calculateArea()))
2. In the Rectangle class, create two attributes named length and width .
3. Write a public…
arrow_forward
Textbook: Joyce Farrell, Microsoft® Visual C#®: An Introduction to Object-Oriented Programming, Seventh Edition, ISBN: 9781337102100.Microsoft Visual C# (chapter 5 code case problem 5-2)
Assignment instruction:
In Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a user for the number of interior and exterior murals scheduled to be painted during a month and computes the expected revenue for each type of mural. The program also prompts the user for the month number and modifies the pricing based on requirements listed in Chapter 4.
Now, modify your program so that the user must enter a month value from 1 through 12. If the user enters an incorrect number, the program prompts for a valid value. Also, the user must enter a number between 0 and 30 inclusive for the number of murals of each type; otherwise, the program prompts the user again.
In order to prepend the $ to currency values, the program will need to use the…
arrow_forward
I need help with this PLEASE NO JAVA NO C++ ONLY PYTHON PLZ
Create a class object with the following attributes and actions:
Class Name
Class number
Classroom
Semester
Level
Subject
Actions:
Store a class list
Print the class list as follows:
Class name Class Number Semester
Level
Subject
Test your object:
Ask the user for all the information and to enter at least 3 classes
test using all the actions of the object
print using the to string action
Describe the numbers and text you print. Do not just print numbers or strings to the screen explain what each number represents.
arrow_forward
Integer userValue is read from input. Assume userValue is greater than 1000 and less than 99999. Assign tensDigit with
userValue's tens place value.
Ex: If the input is 15876, then the output is:
The value in the tens place is: 7
2
3 public class ValueFinder {
4
5
6
7
8
9
10
11
12
13
GHE
14
15
16}
public static void main(String[] args) {
new Scanner(System.in);
}
Scanner scnr
int userValue;
int tensDigit;
int tempVal;
userValue = scnr.nextInt();
Your code goes here */
11
System.out.println("The value in the tens place is: + tensDigit);
arrow_forward
Python Class and Objects
Create a class named "Account" and “Bank”
The class “Account” should have a parameter of
id - integer type
name - string type
balance - float type
# (Optional) You may add more parameters for your convenience
3. Create a method for “Account” class:
checkBalance(self) - this will show the Account's remaining balance or money
withdraw(self, amount) - this will withdraw an amount from the Account
deposit(self, amount) - this will deposit an amount from the Account
# (Optional) You may add more methods like sendMoney() etc.
4. Create a method for “Bank” class:
addAccount(self, account) – used to register an account to the bank
# (Optional) You may add more methods for your convenience
4. Create 3 Account objects with the following attributes in the main method
account1 - id=(any number), name=(Any Name You Want), balance=7000 (strictly use this value)
account2 - id=(any number), name=(Any Name You Want), balance= (any amount)
account3 -…
arrow_forward
python
class Student:def __init__(self, first, last, gpa):self.first = first # first nameself.last = last # last nameself.gpa = gpa # grade point average
def get_gpa(self):return self.gpa
def get_last(self):return self.last
def to_string(self):return self.first + ' ' + self.last + ' (GPA: ' + str(self.gpa) + ')'
class Course:def __init__(self):self.roster = [] # list of Student objects
def drop_student(self, student):# Type your code here
def add_student(self, student):self.roster.append(student)
def count_students(self):return len(self.roster)
if __name__ == "__main__":course = Course()
course.add_student(Student('Henry', 'Nguyen', 3.5))course.add_student(Student('Brenda', 'Stern', 2.0))course.add_student(Student('Lynda', 'Robinson', 3.2))course.add_student(Student('Sonya', 'King', 3.9))
print('Course size:', course.count_students(),'students')course.drop_student('Stern')print('Course size after drop:', course.count_students(),'students')
arrow_forward
python
Cylinder class: Instance variables: Make instance
variables appropriately to accomplish the tasks you
need.
Methods:
?_init_ :: constructor, initializes instance
variables
o Additional Parameters: diameter and height (in
that order)
o Assumption: diameter and height will always be
numbers which represent measurements in
millimeters
o Temporary Assumption (we will fix this later):
diameter will never be negative and height wilI
always be positive number above o
? get_volume : returns the volume of the cylinder
based on its height
o Additional Parameters: No additional parameters
(just self).
.0 Note: Use pi from the math module
?_str__ :: returns string representation with this
format: "Cylinder (radius: 20.25mm, thickness:
6.10mm, volume: 7858.32mm^3)"
o Additional Parameters: No additional parameters.
o Notes: ?
The quotes in the example are just our string
boundaries!
The first character in the above example is C. ?
This method reports the radius (NOT the
diameter). ?
All…
arrow_forward
PYTHON ONLY PLZZZ
Create a class object with the following attributes and actions:
Class Name
Class number
Classroom
Semester
Level
Subject
Actions:
Store a class list
Print the class list as follows:
Class name Class Number Semester
Level
Subject
Test your object:
Ask the user for all the information and to enter at least 3 classes
test using all the actions of the object
print using the to string action
Describe the numbers and text you print. Do not just print numbers or strings to the screen explain what each number represents.
arrow_forward
class Calculator:
# Type your code here.
if __name__ == "__main__":
calc = Calculator(); num1 = float(input()) num2 = float(input())
# 1. The initial value print('{:.1f}'.format(calc.get_value()))
# 2. The The value after adding num1 calc.add(num1) print('{:.1f}'.format(calc.get_value()))
# 3. The value after multiplying by 3 calc.multiply(3) print('{:.1f}'.format(calc.get_value()))
# 4. The value after subtracting num2 calc.subtract(num2) print('{:.1f}'.format(calc.get_value()))
# 5. The value after dividing by 2 calc.divide(2) print('{:.1f}'.format(calc.get_value()))
# 6. The value after calling the clear() method calc.clear() print('{:.1f}'.format(calc.get_value()))
arrow_forward
Focus on classes, objects, methods and good programming styleYour task is to create a BankAccount class using Python.
Class name
BankAccount
Attributes
__balance float float
__pin integer integer
Methods
__init_()get_pin()check_pin()deposit()withdraw()get_balance()
The bank account will be protected by a 4-digit pin number (i.e. between 1000 and 9999). The pin should be generated randomly when the account object is created. The initial balance should be 0.get_pin()should return the pin.check_pin(pin) should check the argument against the saved pin and return True if it matches, False if it does not.deposit(amount) should receive the amount as the argument, add the amount to the account and return the new balance.withraw(amount) should check if the amount can be withdrawn (not more than is in the account), If so, remove the argument amount from the account and return the new balance if the transaction was successful. Return False if it was…
arrow_forward
Convert to C# language only
class Student:def __init__(self,name,eng,math,science):self.Name = nameself.English = engself.Maths = mathself.Science = sciencedef average(self):total = self.English + self.Maths + self.Scienceavg = total / 3return avgdef display(self):print("Name:",self.Name)print("Math:",self.Maths)print("Science:",self.Science)print("English:",self.English)print("Average:", self.average())if self.average() == 100:print("Remarks: Passed")elif self.average() >= 75:print("Remarks: Passed")else:print("Remarks: Failed")name = input("Enter name: ")eng = int(input("Enter marks in English: "))math = int(input("Enter marks in Maths: "))sci = int(input("Enter marks in Science: "))s = Student(name,eng,math,sci)s.display()
arrow_forward
Object-Oriented Programming
❤❤❤ Matchmaker with Java ❤❤❤
Summary: Create a Java application that will determine your true love.
Prerequisites: Java, VS Code, and Terminal
In this assignment you will develop and test a command-line application written in the Java language
that asks questions to determine if a person is your true love. More specifically your application
should ask five questions in the form of statements and allow the user to respond to each statement
with the numbers 1 through 5 with 1 indicating strongly disagree and 5 indicating strongly agree. You
will then compare the person’s answers with your desired “true love” answers. The closer the answers
are to your desired “true love” answers the better match the two of you are for each other.
For example, suppose you choose the statement “Broccoli is delicious.” and your desired answer was
1 (strongly disagree) because you really don’t like broccoli. If the application user entered 4 (agree),
then the two of you would not…
arrow_forward
classname.py -> using "sys.argv"
● Create a program called classname.py. The program should define a class called person that has one method called hello, and one attribute called name, which represents the name of the person. ● The hello method should print the following string to the screen: ‘My name is ____ and I am a _____’ where: ○ The first blank should be the name attribute ○ The second blank should be the name of the class ○ The above blanks should NOT be manually printed (ex. print(‘My name is Greg and I am a person’)) ● After defining the class, there are three things you must do: 1. Instantiate an object of the class 2. Run the hello method of the instantiated object a. (e.g., Greg.hello()) 3. For grading purposes, you must also print the name of the class so I can be sure you’ve created a class a. (The expected output is )
arrow_forward
Course information are created using a class "Course', the class contains:
Course code
java
language
please
Course title
Course number of credits
Course
-code: String
-title: String
-credits: int
+Course (code:String, title:String, credits:int)
+getnfo (): String
+toString (): String
2/4
getinfo() returns course info as follows:
Code: csci410
Title: Mobile Applications
Credits: 3
toString () method returns the title of the course as a string
arrow_forward
CMPG 122
User Interface Programming
Prak 10
Chapter 6: Modularizing Your Code with Methods
1. Charges in a Luxury Resort (Nr 6, Page 410)
Create an application that calculates the total cost of a hotel stay. The daily accommodation
charge is $550. The hotel also provides other services like restaurant and bar, spa, car rental,
and medication and rehabilitation. The application should accept the following input:
E The number of days spent in the hotel
E The restaurant charges including VAT
É The amount accrued from spa and health treatments
E The amount accrued in car rental
E The amount accrued in medical and rehabilitation services
Create and use the following value-returning methods in the application:
A CalcStayCharges () - Calculates and returns the base charges for the hotel stay. This is
computed as $450 times the number of days in the hotel.
e CalcMiscCharges () - Calculates and returns the total of the food bill, spa charges, car
rental, and medication and rehabilitation…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Related Questions
- Enter the name of Stock: Oracle Corporation Enter the symbol of Stock: URCL Enter the previous closing price: 34.5 Enter the current price: 34.35 Stock name: Oracle Corporation Stock symbol: ORCL Stock ID: 59 Price-change percentage: - 0.434782608695648 Challenge Question - Using GregorianCalendar and Date classes: (Use the GregorianCalendar class) Java API has the Date class and GregorianCalendar class in the java.util package, which you can use to obtain the current date with specific details like current year, current month, current day of a date and so on. Write a program to perform these tasks: 1. Display the current year, month, and day. 2. Display the current date by using the to String() method from the Date class. 3. Display the current time-which is used to display the number of milliseconds- by using getTime() method from the Date class. We will use it in the step 17. 4. - Display the current year by using get(GregorianCalendar.YEAR) method from to GregorianCale class. 5-…arrow_forwardEnter the name of Stock: Oracle Corporation Enter the symbol of Stock: URCL Enter the previous closing price: 34.5 Enter the current price: 34.35 Stock name: Oracle Corporation Stock symbol: ORCL Stock ID: 59 Price-change percentage: - 0.434782608695648 Challenge Question - Using GregorianCalendar and Date classes: (Use the GregorianCalendar class) Java API has the Date class and GregorianCalendar class in the java.util package, which you can use to obtain the current date with specific details like current year, current month, current day of a date and so on. Write a program to perform these tasks: 1. Display the current year, month, and day. 2. Display the current date by using the to String() method from the Date class. 3. Display the current time-which is used to display the number of milliseconds- by using getTime() method from the Date class. We will use it in the step 17. 4. - Display the current year by using get(GregorianCalendar.YEAR) method from to GregorianCale class. 5-…arrow_forwardChoose correct option It is disadvantageous to use public variables in classes because ___________ It results in compilation error It cannot control its values It cannot be accessed by other variables Its values cannot be initializedarrow_forward
- Python Code: ###########################################class MovieNode: def __init__(self, title, year, director, genre): self.title = title self.year = year self.director = director self.genre = genre self.next = None self.prev = None def __str__(self): return f"Title: {self.title:<25} Year: {self.year:<6} Director: {self.director:<20} Genre: {self.genre:<10}" def __lt__(self, other): if self.title < other.title: return True else: return False ###########################################class MovieList: def __init__(self): self.head = None self.tail = None def display(self): curr = self.head while curr: print(curr) curr = curr.next # Append new_movie at end of MovieList def append_movie(self, new_movie): # simply adding book to the end of the ddl if self.head == None: self.head = new_movie…arrow_forwardStaff # name: String # id: int PartTimer + Staff() + Staff(name: String, id: int) skillLevel: int + getName (): String + getId (): int + calculatePay () : double + toString (): String hoursWorked: int + Part Timer (name: String, id: int, skillLevel: int, hoursWorked: int) + getskillLevel(): int + getHours Worked () : int + tostring () : String java.lang.Comparable compareTo (o: Object): int Figure 1: The relationship between staff, PartTimer and Comparable Skill Level / Tahap Kemahiran Pay Rate Per Hour/ Kadar Bayaran Per Jam 0 ( Basic / Asas) RM50.00 1 (Moderate / Sederhana) RM100.00 RM150.00 2 (Expert / Mahir) Table 1: Skill level and the pay rate per hour Write a complete Java program to create PartTimer class and test class based on the Figure 1, Table 1 and the following requirements: Partimer class is derived from staff and implements Comparable Interface. The calculate Pay()method from the staff class will be implemented in the subclass to calculate the employee's pay. The pay…arrow_forwardIn Python: Design a class named AutomobileLoan that holds: a loan number make of automobile model of automobile balance of loan Include methods to: set values for each data field displays all the loan information Create the class diagram and write the pseudocode that defines the class. Design an application using pseudocode that: declares two AutomobileLoan objects sets the values of both objects displays the values of both objects Deliverables Class Diagram Pseudocode that defines the class Pseudocode that declares, sets, and displays 2 AutomobileLoan objectsarrow_forward
- What will this code print? def fun_a(): print("aa") def fun_b(): print("bb") def fun_c(): print("cc") def main(): fun_c() fun_a() fun_b() fun_c() Question 13 options: cc aa bb cc aa bb cc aa cc bb cc cc bb aa nothingarrow_forwardga Class in Python Creating a Class in Python MyRectangleClassPro. Rectangle.py 1 # This program uses the programmer-defined Rectangle class. 2 Summary 3 # Do NOT modify this program. Write your code in Rectangle.py, 4 # then select this file and click "Run Code". In this lab, you create a programmer-defined class and then use it in a Python program. The 5 program should create two Rectangle objects and find their area and perimeter. 6 from Rectangle import Rectangle 7 8 rectanglel = Rectangle(10.0, 5.0) 9 rectangle2 = Rectangle(7.0, 3.0) Instructions 10 1. Open the class file named Rectangle.py 11 print("Perimeter of rectanglel is " + str(rectanglel.calculatePerimeter())) 12 print("Area of rectanglel is " + str(rectanglel.calculateArea())) 13 print("Perimeter of rectangle2 is " + str(rectangle2.calculatePerimeter())) 14 print("Area of rectangle2 is " + str(rectangle2.calculateArea())) 2. In the Rectangle class, create two attributes named length and width . 3. Write a public…arrow_forwardTextbook: Joyce Farrell, Microsoft® Visual C#®: An Introduction to Object-Oriented Programming, Seventh Edition, ISBN: 9781337102100.Microsoft Visual C# (chapter 5 code case problem 5-2) Assignment instruction: In Chapter 4 of your book, you created an interactive application named MarshallsRevenue that prompts a user for the number of interior and exterior murals scheduled to be painted during a month and computes the expected revenue for each type of mural. The program also prompts the user for the month number and modifies the pricing based on requirements listed in Chapter 4. Now, modify your program so that the user must enter a month value from 1 through 12. If the user enters an incorrect number, the program prompts for a valid value. Also, the user must enter a number between 0 and 30 inclusive for the number of murals of each type; otherwise, the program prompts the user again. In order to prepend the $ to currency values, the program will need to use the…arrow_forward
- I need help with this PLEASE NO JAVA NO C++ ONLY PYTHON PLZ Create a class object with the following attributes and actions: Class Name Class number Classroom Semester Level Subject Actions: Store a class list Print the class list as follows: Class name Class Number Semester Level Subject Test your object: Ask the user for all the information and to enter at least 3 classes test using all the actions of the object print using the to string action Describe the numbers and text you print. Do not just print numbers or strings to the screen explain what each number represents.arrow_forwardInteger userValue is read from input. Assume userValue is greater than 1000 and less than 99999. Assign tensDigit with userValue's tens place value. Ex: If the input is 15876, then the output is: The value in the tens place is: 7 2 3 public class ValueFinder { 4 5 6 7 8 9 10 11 12 13 GHE 14 15 16} public static void main(String[] args) { new Scanner(System.in); } Scanner scnr int userValue; int tensDigit; int tempVal; userValue = scnr.nextInt(); Your code goes here */ 11 System.out.println("The value in the tens place is: + tensDigit);arrow_forwardPython Class and Objects Create a class named "Account" and “Bank” The class “Account” should have a parameter of id - integer type name - string type balance - float type # (Optional) You may add more parameters for your convenience 3. Create a method for “Account” class: checkBalance(self) - this will show the Account's remaining balance or money withdraw(self, amount) - this will withdraw an amount from the Account deposit(self, amount) - this will deposit an amount from the Account # (Optional) You may add more methods like sendMoney() etc. 4. Create a method for “Bank” class: addAccount(self, account) – used to register an account to the bank # (Optional) You may add more methods for your convenience 4. Create 3 Account objects with the following attributes in the main method account1 - id=(any number), name=(Any Name You Want), balance=7000 (strictly use this value) account2 - id=(any number), name=(Any Name You Want), balance= (any amount) account3 -…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT