
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
-
Code Example 18-2
1. import tkinter as tk
2. from tkinter import ttk
3. class TipCalcFrame(ttk.Frame):
4. def __init__(self, parent):
5. ttk.Frame.__init__(self, parent, padding="20 20 20 20")
6. self.pack()
7. self.mealCost = tk.StringVar()
8. self.tipPercent = tk.StringVar()
9. self.tipAmount = tk.StringVar()
10. ttk.Label(self, text="Cost of your meal:").grid(
column=0, row=0, sticky=tk.E)
11. ttk.Entry(self, width=30, textvariable=self.mealCost).grid(
column=1, row=0)
12. ttk.Label(self, text="Percent to leave as a tip:").grid(
column=0, row=1, sticky=tk.E)
13. ttk.Entry(self, width=30, textvariable=self.tipPercent).grid(
column=1, row=1)
14. ttk.Label(self, text="Tip amount:").grid(
column=0, row=2, sticky=tk.E)
15. ttk.Entry(self, width=30, textvariable=self.tipAmount,
state="readonly").grid(column=1, row=2)
16. ttk.Button(self, text="Calculate",
command=self.calculate).grid(column=1,row=3, sticky=tk.E)
17. for child in self.winfo_children():
18. child.grid_configure(padx=5, pady=3)
19. def calculate(self):
20. mealCost = float(self.mealCost.get())
21. tipPercent = float(self.tipPercent.get())
22. tipPercent = tipPercent/100
23. tip = mealCost * tipPercent
24. yourTip = "$" + str(round(tip, 2))
25. self.tipAmount.set(yourTip)
26. if __name__ == "__main__":
27. root = tk.Tk()
28. root.title("Tip Calculator")
29. TipCalcFrame(root)
30. root.mainloop()
Refer to Code Example 18-2: What does the GUI do if the user enters the cost of the meal and the tip percent and clicks the Calculate button?a. It calculates the amount of a tip to leave based on the user’s input, but it can’t display it because the Entry text field is read only.b. It calculates and displays the amount of a tip to leave based on the user’s input.c. It calculates and displays the total amount to leave based on the user’s input.d. It doesn’t do anything because the calculate() method isn’t connected to the Calculate button.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
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
- Create a class Rectangle with length and breadth as private data members and also provide the following member functions: getdata(): gets the length and breadth of rectangle. calarea(): return the area of the rectangle. calperi(): return the perimeter of the rectangle. issquare(): return true if the rectangle is squarearrow_forward2. Team Class a. Variables i. Trainer -> String Gym - >String Members ->arrayList of type pokemon iv. ii. ii. saveFile ->a constant string that is the filename of "teamData.record" b. Methods i. Accessor and Mutator methods for all variables ii. setTeam - >sets all variables for a team ii. 2 Constructors addMember 1. Add a pokemon to the members arraylist 2. readlnput for such pokemon V. saveData 1. Writes all data from this class to the binary file saveFile vi. loadData 1. Loads data from saveFile 2. Set the team using the setTeam method vii. writeOutput 1. Prints all data for a team including printing all data for each pokemon in the members arraylist 2. Before printing pokemon data, ensure that you use Collections.sort(members) on the members arrayList. You can look up how this method works, but it should use the compareTo that we set up in the pokemon class and sort the pokemon into alphabetical order before printing.arrow_forward15arrow_forward
- class ClubMember:def __init__(self,id,name,gender,weight,phone):self.id = idself.name = nameself.gender = genderself.weight = weightself.phone = phonedef __str__(self):return "Id:"+str(self.id)+",Name:"+self.name+",Gender:"+self.gender+",Weight:"+str(self.weight)+",Phone:"+str(self.phone) class Club:def __init__(self,name):self.name = nameself.members = {}self.membersCount = 0def run(self):print("Welcome to "+self.name+"!")while True:print("""1. Add New Member2. Delete a Member3. Search for a member4. Browse All Members5. Edit Member6. Exit""")choice = int(input("Choice:"))if choice == 1:self.membersCount = self.membersCount+1id = self.membersCountname = input("Member name:")gender = input("Gender:")weight = int(input("Weight:"))phone = int(input("Phone No."))member = ClubMember(id,name,gender,weight,phone)self.members[id] = memberelif choice == 2:id = int(input("Enter id of member to delete:"))del self.members[id]break elif choice == 3:id = int(input("Enter member id to…arrow_forwardimport bridges.base.ColorGrid;import bridges.base.Color;public class Scene {/* Creates a Scene with a maximum capacity of Marks andwith a background color.maxMarks: the maximum capacity of MarksbackgroundColor: the background color of this Scene*/public Scene(int maxMarks, Color backgroundColor) {}// returns true if the Scene has no room for additional Marksprivate boolean isFull() {return false;}/* Adds a Mark to this Scene. When drawn, the Markwill appear on top of the background and previously added Marksm: the Mark to add*/public void addMark(Mark m) {if (isFull()) throw new IllegalStateException("No room to add more Marks");}/*Helper method: deletes the Mark at an index.If no Marks have been previously deleted, the methoddeletes the ith Mark that was added (0 based).i: the index*/protected void deleteMark(int i) {}/*Deletes all Marks from this Scene thathave a given Colorc: the Color*/public void deleteMarksByColor(Color c) {}/* draws the Marks in this Scene over a background…arrow_forward. Protected variables coth Task 1.1: Base Animai Create Animal Class with 3 protected attributes: • name - String • type-String • nocturnal - boolean • 4 public void Methods: • printInfo-should print: " is a(n) ." • printSleepInfo-should print: "s sleep during day." or "s sleep during night." • printRoam - should print: " walks around." • printFeed method - will implement in subclasses ● Subclass Owl: Constructor takes in name as argument and sets the attributes: • Type should be "Owl", nocturnal should be true and name is given as the argument ia printFeed method: • Should print "You give some mice." Overriding roam method: • Should print " flies around." Subclass Monkey: • Similar constructor: • Type should be "Monkey", nocturnal should be false and name is given as the argument printFeed method: Should print "You give some bananas." Create another public method called printClimb: Should print " climbs a tree!" Overriding roam method of owl as owls fly Animal printInfo():void…arrow_forward
- class SavingsAccount(object): RATE = 0.02 def __init__(self, name, pin, balance = 0.0): self._name = name self._pin = pin self._balance = balance def __str__(self): result = 'Name: ' + self._name + '\n' result += 'PIN: ' + self._pin + '\n' result += 'Balance: ' + str(self._balance) return result def __eq__(self,a): if self._name == a._name and self._pin == a._pin and self._balance == a._balance: return True else: return False def __gt__(self,a): if self._balance > a._balance: return True else: return False def getBalance(self): return self._balance def getName(self): return self._name def getPin(self): return self._pin def deposit(self, amount): self._balance += amount return self._balance…arrow_forward28arrow_forward1. Create the main method using pythone to test the classes. #Create the class personTypefrom matplotlib.pyplot import phase_spectrum class personType: #create the class constructor def __init__(self,fName,lName): #Initialize the data members self.fName = fName self.lName = lName #Method to access def getFName(self): return self.fName def getLName(self): return self.lName #Method to manipulate the data members def setFName(self,fName): self.fName = fName def setLName(self,lName): self.lName = lName #Create the class Doctor Type inherit from personTypeclass doctorType(personType): #Create the constructor for the doctorType class def __init__(self, fName, lName,speciality="unknown"): super().__init__(fName, lName) self.speciality = speciality #Methods to access def getSpeciality(self): return self.speciality #Methods to manipulate def setSpeciality(self,spc):…arrow_forward
- // Declare data fields: a String named customerName, // an int named numItems, and // a double named totalCost.// Your code here... // Implement the default contructor.// Set the value of customerName to "no name"// and use zero for the other data fields.// Your code here... // Implement the overloaded constructor that// passes new values to all data fields.// Your code here... // Implement method getTotalCost to return the totalCost.// Your code here... // Implement method buyItem.//// Adds itemCost to the total cost and increments// (adds 1 to) the number of items in the cart.//// Parameter: a double itemCost indicating the cost of the item.public void buyItem(double itemCost){// Your code here... }// Implement method applyCoupon.//// Apply a coupon to the total cost of the cart.// - Normal coupon: the unit discount is subtracted ONCE// from the total cost.// - Bonus coupon: the unit discount is subtracted TWICE// from the total cost.// - HOWEVER, a bonus coupon only applies if the…arrow_forwardCreate a class called Staff that has the following attributes: Staff String - FirstName String - LastName String - Department String - Title Integer - UIN Staff() Staff(FirstName, LastName, Department, Title, UIN) getFirstName() - String setFirstName(String) - void getLastName() - String setLastName(String) - void getDepartment() - String setDepartment(String) - void getTitle() - String setTitle(String) - void getUIN() - Integer setUIN(Integer) - void toString() - String compareTo(Staff) - Integer equals(Staff) - Boolean PreviousNextarrow_forward#ClubMember classclass ClubMember: #__init_ functiondef __init__(self,id,name,gender,weight,phone):self.id = idself.name = nameself.gender = genderself.weight = weightself.phone = phone #__str__ functiondef __str__(self):return "Id:"+str(self.id)+",Name:"+self.name+",Gender:"+self.gender+",Weight:"+str(self.weight)+",Phone:"+str(self.phone) #Club classclass Club: #__init__ functiondef __init__(self,name):self.name = nameself.members = {}self.membersCount = 0 def run(self):print("Welcome to "+self.name+"!")while True:print("""1. Add New Member2. View Member Info3. Search for a member4. Browse All Members5. Edit Member6. Delete a Member7. Exit""") choice = int(input("Choice:")) if choice == 1:self.membersCount = self.membersCount+1id = self.membersCountname = input("Member name:")gender = input("Gender:")weight = int(input("Weight:"))phone = int(input("Phone No.")) member = ClubMember(id,name,gender,weight,phone)self.members[id] = memberelif choice == 2:name = input("Enter name of…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education