You are on page 1of 5

08 Task

Performance
1
(Data Structure and Algorithms)

This study source was downloaded by 100000834833909 from CourseHero.com on 12-18-2021 01:53:54 GMT -06:00

https://www.coursehero.com/file/117897770/JACOBE-08-Task-Performance-1docx/
import java.util.*;
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

public class StudentList {

public static void main(String[] args) {


HashMap<String, String>students = new HashMap<>();
Scanner input = new Scanner(System.in);

String name = "";


String studentnumber = "";
System.out.print("Enter Student number 1:");
studentnumber = input.nextLine();
System.out.print("Enter Student name 1:");
name = input.nextLine();
students.put(studentnumber,name);
System.out.print("Enter Student number 2:");
studentnumber = input.nextLine();
System.out.print("Enter Student name 2:");
name = input.nextLine();
students.put(studentnumber,name);
System.out.print("Enter Student number 3:");
studentnumber = input.nextLine();
System.out.print("Enter Student name 3:");
name = input.nextLine();
students.put(studentnumber,name);
System.out.println(students.keySet());
System.out.println(students.values());
students.remove(studentnumber,name);
System.out.print("Enter Student number :");
studentnumber = input.next();
System.out.print("Enter your first name:");
name = input.next();
students.put(studentnumber, name);
System.out.println("Student List:");
for(HashMap.Entry e: students.entrySet()) {
System.out.println(e.getKey() + "" + e.getValue());
}
}

This study source was downloaded by 100000834833909 from CourseHero.com on 12-18-2021 01:53:54 GMT -06:00

https://www.coursehero.com/file/117897770/JACOBE-08-Task-Performance-1docx/
This study source was downloaded by 100000834833909 from CourseHero.com on 12-18-2021 01:53:54 GMT -06:00

https://www.coursehero.com/file/117897770/JACOBE-08-Task-Performance-1docx/
Student_List.py:

HashMap = {20180017:"nana", 20180134:"brody", 20180004:"muning"}

students = {}

for i in range(1,4):

studNum = input("Enter student number" + str(i) +":" )

studFname = input ("Enter first name " + str (i)+ ":")

students[studNum] = studFname

print("Student List:")

for key, value in HashMap.items() :

print (key, value)

HashMap = {20180017:"nana", 20180134:"brody", 20180046:"olaf"}

studNum = input("Enter student number:" )

studFname = input ("Enter first name:")

students[studNum] = studFname

print("Student List:")

for key, value in HashMap.items() :

print (key, value)

This study source was downloaded by 100000834833909 from CourseHero.com on 12-18-2021 01:53:54 GMT -06:00

https://www.coursehero.com/file/117897770/JACOBE-08-Task-Performance-1docx/
This study source was downloaded by 100000834833909 from CourseHero.com on 12-18-2021 01:53:54 GMT -06:00

https://www.coursehero.com/file/117897770/JACOBE-08-Task-Performance-1docx/
Powered by TCPDF (www.tcpdf.org)

You might also like