Subjects
PRICING
TEST PREP
SIGN IN
Start Free Trial
Anand R.
Tutor for four years, Summer Research Fellow at Indian Academy of Sciences
Tutor Satisfaction Guarantee
Python Programming
TutorMe
Question:

Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. The program should present a menu that lets the user perform the following actions:  Look up an employee in the dictionary  Add a new employee to the dictionary  Change an existing employee’s name, department, and job title in the dictionary  Delete an employee from the dictionary  Quit the program

Anand R.
Answer:

# This program uses the Employee class to make an Employee Management System from Employee class Employee: #Initiate variables for name, ID number, department, and job title def __init__(self, ID, name, dept, title): self.ID = ID self.name = name self.dept = dept self.title = title #Create set functions for each variable def set_ID(self, ID): self.ID = ID def set_name(self, name): self.name = name def set_dept(self, dept): self.dept = dept def set_title(self, title): self.title = title #Create get functions for each variable def get_ID(self): return self.ID def get_name(self): return self.name def get_dept(self): return self.dept def get_title(self): return self.title # Initialize a empty dictionary #You can substitute the following line with your details or any random values. #This is just an initialization, which is not compulsory for running the program! #In case if you remove this initialization, Startthe program with adding new Employee e=Employee('1','AAAA','Computer Science','Tutor') employees = {} employees[e.get_ID()] = [e.get_name(), e.get_dept(), e.get_title()] #The following line is to just to make sure that initialisation worked print(employees) # Main function displays menu options def main(): while True: select = input("""What would you like to do? Look up an employee - enter 1 Add a new employee - enter 2 Change employee's information - enter 3 Delete an employee - enter 4 Enter any other key to quit the program: """) if select == '1': # call this function and remove the 'continue' #Here, the function look_up has been called to initiate the looking up process #Note that the employees dictionary is passed with the function look_up(employees) elif select == '2': add_employee() elif select == '3': change_info() elif select == '4': # call this function and remove the 'continue' #The same changes as in the case of look up function is made here also except that the function called here #is delete owing to the purpose delete(employees) else: break # make function to: Look up an employee in the dictionary # Look up an employee name in the employee dictionary def look_up(employee): # Get a name to look up name = input('Enter an employee name: ') #We have Employee ID as the key. Hence, we run a search procedure to find the corresponding key for the name entered for key, val in employee.items(): #This iterates between the values in the dictionary and finds the key and value if name in val: print(employee[key]) #the employee details are displayed if found else: print('Not found.') # Add a new employee to the dictionary def add_employee(): addID = input('Enter the employee\'s ID number: ') addname = input('Enter the employee\'s name: ') adddept = input('Enter the employee\'s department: ') addtitle = input('Enter the employee\'s job title: ') new_employee = Employee(addID, addname, adddept, addtitle) employees[new_employee.get_ID()] = [new_employee.get_name(), new_employee.get_dept(), new_employee.get_title()] print('Added Successfully') print(employees)#To show the updated list # Change an existing employee's name, dept, and job title in the dictionary def change_info(): key = input('Enter the ID number of the employee: ') updateName = input('Enter the employee\'s updated name: ') updateDepartment = input('Enter the employee\'s updated department: ') updateTitle = input('Enter the employee\'s updated title: ') employees[key] = [updateName, updateDepartment, updateTitle] print('Updated Successfully') print(employees)#To show the updated list # make function to: Delete an employee from the dictionary # Delete function deletes entry from employee dictionary def delete(employee): # Get the name of employee to be deleted name = input('Enter a name: ') # If name is not found, delete the entry #Here the key search is run for the entered name. for key, val in employee.items(): if name in val: del employee[key] #Deletes the Employee if found print('Deleted Successfully') break #Once the deletion is done, there is no need of further iteration else: print('That name is not found') print(employees)#Displays the updated list # Call the main Function main() main() #this print statement is just so you can see the result at the end of running the program. print(employees)

Trigonometry
TutorMe
Question:

Prove that {\displaystyle \sin[\arctan(x)]={\frac {x}{\sqrt {1+x^{2}}}}} \sin[\arctan(x)]=\frac{x}{\sqrt{1+x^2}}

Anand R.
Answer:

We start from {\displaystyle \sin ^{2}\theta +\cos ^{2}\theta =1} \sin ^{2}\theta +\cos ^{2}\theta =1 Then we divide this equation by {\displaystyle \cos ^{2}\theta } \cos ^{2}\theta {\displaystyle \cos ^{2}\theta ={\frac {1}{\tan ^{2}\theta +1}}} \cos ^{2}\theta ={\frac {1}{\tan ^{2}\theta +1}} Then use the substitution {\displaystyle \theta =\arctan(x)} \theta =\arctan(x), also use the Pythagorean trigonometric identity: {\displaystyle 1-\sin ^{2}[\arctan(x)]={\frac {1}{\tan ^{2}[\arctan(x)]+1}}} 1-\sin ^{2}[\arctan(x)]={\frac {1}{\tan ^{2}[\arctan(x)]+1}} Then we use the identity {\displaystyle \tan[\arctan(x)]\equiv x} \tan[\arctan(x)]\equiv x {\displaystyle \sin[\arctan(x)]={\frac {x}{\sqrt {x^{2}+1}}}}

C++ Programming
TutorMe
Question:

Problems in computations include mathematical precision (i.e. double, float, long, integer) especially when using mixed mode arithmetic. An aspect of using IF statements is to control what appears to the user. Applications must also provide the data in a “useable” and readable format for the user hence formatting for any currency. This application will: 1. Allow the user to enter a dollar amount (i.e. $37.21, $563.44, $.077) 2. Determine the number of: a. Twenty dollar bills (2,000 pennies) b. Ten dollar bills (1,000 pennies) c. Five dollar bills (500 pennies) d. One dollar bills (100 pennies) e. Fifty cent pieces (50 pennies) f. Quarters (25 pennies) g. Dimes (10 pennies) h. Nickels (5 pennies) i. Pennies (1 penny) for that dollar amount

Anand R.
Answer:

#include<iostream> //Standard I/O class #include<conio.h> int main() //calling the main function { using namespace std; float dollar,pennies; //defining the variables for dollars and pennies cout<<"\n Enter the amount in dollars: "; cin>>dollar;//Getting the a dollar amount from the user pennies=(dollar*100);//Converting dollar into pennies int penny;//defining a new variable to store the converted integral value of pennies penny=pennies;//Type casting pennies of float type into int cout<<" \n"<<dollar<<" dollars is "<<penny<<" pennies"; //displaying the amount in pennies int rem;//defining a dummy variable to show different values if(penny>0)// { rem=penny/2000;//acquiring the number of 20 dollar bills penny=penny%2000;//getting the remainder amount after taking the number of dollar bills if(rem!=0)//Checking whether 20 dollar bills are required cout<<" \n"<<rem<<" 20 dollar bills ";//displaying the number of 20 dollar bills if(penny!=0)//Checking whether the remainder amount is zero { rem=penny/1000;//acquiring the number of 10 dollar bills penny=penny%1000;//getting the remainder amount after taking the number of dollar bills if(rem!=0)//Checking whether 10 dollar bills are required cout<<" \n"<<rem<<" 10 dollar bills ";//displaying the number of 10 dollar bills } // The above process is repeated for different denominations in the following lines of code if(penny!=0) { rem=penny/500; penny=penny%500; if(rem!=0) cout<<" \n"<<rem<<" 5 dollar bills "; } if(penny!=0) { rem=penny/100; penny=penny%100; if(rem!=0) cout<<" \n"<<rem<<" 1 dollar bills "; } if(penny!=0) { rem=penny/50; penny=penny%50; if(rem!=0) cout<<"\n"<<rem<<" 50 cent pieces "; } if(penny!=0) { rem=penny/25; penny=penny%25; if(rem!=0) cout<<"\n"<<rem<<" quarters "; } if(penny!=0) { rem=penny/10; penny=penny%10; if(rem!=0) cout<<"\n"<<rem<<" dimes "; } if(penny!=0) { rem=penny/5; penny=penny%5; if(rem!=0) cout<<"\n"<<rem<<" nickels "; } if(penny!=0) { rem=penny/1; penny=penny%1; if(rem!=0) cout<<"\n"<<rem<<" pennies "; } } else//If the entered value is 0 dollars cout<<" \n You have entered 0 dollars!";//Displaying the error getch(); return 0; }

Send a message explaining your
needs and ANAND will reply soon.
Contact ANAND
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.