note 116531 added to language.functions
| From: | aneesingh0957 at gmail dot com | Date: | Mon, 19 Jan 2015 15:23:43 +0000 |
| Subject: | note 116531 added to language.functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201458@lists.php.net to get a copy of this message | ||
import java.util.Scanner;
import java.lang.*;
public class stud{
private String name;
private int roll;
private int age;
Scanner no = new Scanner(System.in);
public stud()
{name=null;
roll=0;
age=0;
}
public void input()
{
name=no.nextLine();
roll=no.nextInt();
age=no.nextInt();
}
public void display()
{System.out.println("\n"+name+"\t"+roll+"\t"+age);
}
public static void main(String args[]){
Scanner n = new Scanner(System.in);
stud[] s= new stud[10];
System.out.println("Enter the no of students :");
int num = n.nextInt();
for(int i=0;i<num;i++)
{s[i]=new stud();
System.out.println("Enter name, roll, age of student no "+ i+1);
s[i].input();
}
int y=0;
while(y==0)
{
System.out.println("Enter your choice\n1.Display\n2.Search\n3.Delete");
int x = n.nextInt();
switch(x)
{case 1:
System.out.println("\nNAME\tROLL\tAGE");
for(int i=0;i<num;i++)
{s[i].display();
}
break;
case 2:
String sname;
System.out.println("Enter name:");
sname=n.next();
int temp=0;
System.out.println("\nNAME\tROLL\tAGE");
for(int i=0;i<num;i++)
{if(s[i].name.equals(sname))
{s[i].display();
temp++;
break;
}
}
if(temp==0)
System.out.println("This name does not exists in file");
break;
case 3:
String stname;
System.out.println("Enter name:");
stname=n.next();
int tmp=0;
for(int i=0;i<num;i++)
{if(s[i].name.equals(stname))
{String del=s[i].name;
int j;
for(j=i;j<num;j++)
s[j]=s[j+1];
num--;
System.out.println("Deleted:\t"+del);
tmp++;
break;
}
}
if(tmp==0)
System.out.println("This name does not exists in file");
break;
default:
System.out.println("Wrong Choice");
break;
}
System.out.println("\nEnter your choice\n\n1.More\n2.Exit\n");
int choice=n.nextInt();
if(choice==1)
y=0;
else
y++;
}
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 116.68.123.123
----
Manual Page -- http://php.net/manual/en/language.functions.php
Edit -- https://master.php.net/note/edit/116531
Del: integrated -- https://master.php.net/note/delete/116531/integrated
Del: useless -- https://master.php.net/note/delete/116531/useless
Del: bad code -- https://master.php.net/note/delete/116531/bad+code
Del: spam -- https://master.php.net/note/delete/116531/spam
Del: non-english -- https://master.php.net/note/delete/116531/non-english
Del: in docs -- https://master.php.net/note/delete/116531/in+docs
Del: other reasons-- https://master.php.net/note/delete/116531
Reject -- https://master.php.net/note/reject/116531
Search -- https://master.php.net/manage/user-notes.php