Write a program to print the worker’s informations (Name age, salary) in records format.
Answers
Import java.util.*;
class worker
{
static void main ()
{
Scanner in=new Scanner (System.in);
int age=0;
String name=" ";
double salary=0.0;
Sop("Enter the workers name :");
name=in.nextLine().toUpperCase();
Sopln("Enter the age : ");
age=in.nextInt ();
Sopln("Enter the salary : ");
Sopln("NAME \t\t\t\t AGE \t\t\t\t SALARY ");
Sopln(name+"\t\t\t\t "+age+"\t\t\t\t "+salary);
}
}
The following cσdes have been written using Python.
n = int(input("Enter the number of employees: "))
emp_dict = dict()
print()
for i in range(n):
x = input("Enter the name of the employee: ")
y = int(input("Enter the age: "))
z = float(input("Enter the salary: "))
emp_dict[x] = [y, z]
print()
print()
print("Your given dictionary: ")
print()
print("Name\t", "Age\t", "Salary")
print()
for i in emp_dict:
print(i, "\t", emp_dict[i][0], "\t", emp_dict[i][1])