Python Program
Do not use import please. Problem 1: Rolodex (Note: A Rolodex is a Contact List) Write a
program that manages a rolodex. This program prompts the user for the name of a rol file. This
program should be able to load any rol file and require that the file extension -i.e the last 4 letters
of the file be rol. The file rol is consider a valid file. If the file exists the program loads in the
contacts stored in the file. A Rolodex contains unique individuals, no duplicate names are
allowed. However, name lookups are case sensitive, so \"Apple\" and \"apple\" are considered
different names allowed However, name
Solution
Rolodex.java
public class Rolodex{
String name;
String phone;
String email;
String note;
Rolodex(String name,String phone,String email,String note){
this.name=name;
this.phone=phone;
this.email=email;
this.note=note;
}
public String tostring(){
return \"name:\"+name+\"\ phone:\"+phone +\"\ email:\"+email+ \"\ note:\"+note;
}
}
rolodexmain.java
import java.util.*;
public class rolodexmain {
static Scanner sc=new Scanner(System.in);
static Listlist=new ArrayList();
static Setsets=new HashSet();
public static void main(String[] args) {
// TODO Auto-generated method stub
while(true){
System.out.println(\"Rolodex comands \\t Insert(i),remove(R),
Lookbyname(F),LookbyPhone number(N),Lookby email(E)saves(S),save and
quit(Q),printall(P),quit and dont save(X)\");
char ch=sc.next().charAt(0);
switch(ch){
case \'I\':
insert(list);
break;
case \'R\':
deleted(list);
break;
case \'F\':
Lookbyname(list);
break;
case \'N\':
Lookbyphonenumber(list);
break;
case \'E\':
Lookbyemail(list);
break;
case \'P\':
printall(list);
break;
case \'X\':
System.exit(0);
case \'S\':
saves(list);
break;
case \'Q\':
savesandquit(list);
System.exit(0);
}
}
}
public static void insert(List list){
System.out.println(\"please enter contact name:\");
String name=sc.next();
System.out.println(\"please enter contact phone number:\");
String phone=sc.next();
System.out.println(\"please enter contact email id:\");
String email=sc.next();
System.out.println(\"please enter contact note:\");
String note=sc.next();
Rolodex r=new Rolodex(name,phone,email,note);
list.add(r);
}
public static void deleted(List list){
boolean flag=false;
System.out.println(\"enter name of contact to delete :\");
String dname=sc.next();
for(int i=0;i list){
System.out.println(\"enter name of contact which you want to look :\");
String lname=sc.next();
for(int i=0;i list){
System.out.println(\"please enter phone number which you want to look:\");
String lphone=sc.next();
for(int i=0;i list){
System.out.println(\"please enter phone number which you want to look:\");
String lemail=sc.next();
for(int i=0;i list){
for(int i=0;i list){
sets.addAll(list);
for (Rolodex o : sets) {
// Rolodex r=(Rolodex)sets;
System.out.println(o.tostring());
}
}
public static void savesandquit(List list){
sets.addAll(list);
for (Rolodex o : sets) {
// Rolodex r=(Rolodex)sets;
System.out.println(o.tostring());
}
}.
Python ProgramDo not use import please. Problem 1 Rolodex (Note .pdf
1. Python Program
Do not use import please. Problem 1: Rolodex (Note: A Rolodex is a Contact List) Write a
program that manages a rolodex. This program prompts the user for the name of a rol file. This
program should be able to load any rol file and require that the file extension -i.e the last 4 letters
of the file be rol. The file rol is consider a valid file. If the file exists the program loads in the
contacts stored in the file. A Rolodex contains unique individuals, no duplicate names are
allowed. However, name lookups are case sensitive, so "Apple" and "apple" are considered
different names allowed However, name
Solution
Rolodex.java
public class Rolodex{
String name;
String phone;
String email;
String note;
Rolodex(String name,String phone,String email,String note){
this.name=name;
this.phone=phone;
this.email=email;
this.note=note;
}
public String tostring(){
return "name:"+name+" phone:"+phone +" email:"+email+ " note:"+note;
}
}
rolodexmain.java
import java.util.*;
public class rolodexmain {
static Scanner sc=new Scanner(System.in);
static Listlist=new ArrayList();
2. static Setsets=new HashSet();
public static void main(String[] args) {
// TODO Auto-generated method stub
while(true){
System.out.println("Rolodex comands t Insert(i),remove(R),
Lookbyname(F),LookbyPhone number(N),Lookby email(E)saves(S),save and
quit(Q),printall(P),quit and dont save(X)");
char ch=sc.next().charAt(0);
switch(ch){
case 'I':
insert(list);
break;
case 'R':
deleted(list);
break;
case 'F':
Lookbyname(list);
break;
case 'N':
Lookbyphonenumber(list);
break;
case 'E':
Lookbyemail(list);
break;
case 'P':
printall(list);
break;
case 'X':
3. System.exit(0);
case 'S':
saves(list);
break;
case 'Q':
savesandquit(list);
System.exit(0);
}
}
}
public static void insert(List list){
System.out.println("please enter contact name:");
String name=sc.next();
System.out.println("please enter contact phone number:");
String phone=sc.next();
System.out.println("please enter contact email id:");
String email=sc.next();
System.out.println("please enter contact note:");
String note=sc.next();
Rolodex r=new Rolodex(name,phone,email,note);
list.add(r);
}
public static void deleted(List list){
boolean flag=false;
System.out.println("enter name of contact to delete :");
String dname=sc.next();
for(int i=0;i list){
4. System.out.println("enter name of contact which you want to look :");
String lname=sc.next();
for(int i=0;i list){
System.out.println("please enter phone number which you want to look:");
String lphone=sc.next();
for(int i=0;i list){
System.out.println("please enter phone number which you want to look:");
String lemail=sc.next();
for(int i=0;i list){
for(int i=0;i list){
sets.addAll(list);
for (Rolodex o : sets) {
// Rolodex r=(Rolodex)sets;
System.out.println(o.tostring());
}
}
public static void savesandquit(List list){
sets.addAll(list);
for (Rolodex o : sets) {
// Rolodex r=(Rolodex)sets;
System.out.println(o.tostring());
}
}
}
output:
Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
I
please enter contact name:
5. SWARUP
please enter contact phone number:
567889
please enter contact email id:
SWARUP@
please enter contact note:
CONTACT
Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
I
please enter contact name:
ALISA
please enter contact phone number:
123
please enter contact email id:
ALISE@
please enter contact note:
NEW
Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
F
enter name of contact which you want to look :
SWARUP
name:SWARUP
phone:567889
email:SWARUP@
note:CONTACT
Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
N
please enter phone number which you want to look:
567889
name:SWARUP
phone:567889
email:SWARUP@
note:CONTACT
6. Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
E
please enter phone number which you want to look:
ALISE@
name:ALISA
phone:123
email:ALISE@
note:NEW
Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
P
name:SWARUP
phone:567889
email:SWARUP@
note:CONTACT
name:ALISA
phone:123
email:ALISE@
note:NEW
Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
S
name:ALISA
phone:123
email:ALISE@
note:NEW
name:SWARUP
phone:567889
email:SWARUP@
note:CONTACT
Rolodex comands Insert(i),remove(R), Lookbyname(F),LookbyPhone number(N),Lookby
email(E)saves(S),save and quit(Q),printall(P),quit and dont save(X)
X