Future Vision BIE Future Vision BIE


ONE STOP FOR ALL STUDY MATERIALS & LAB PROGRAMS


E MENU Whatsapp Share Join Telegram, to get Instant Updates
× NOTE! Click on MENU to Browse between Subjects...

Advertisement

Advertisement

DESIGN AND ANALYSIS OF ALGORITHMS LABORATORY

(Effective from the academic year 2018 -2019)

SEMESTER - IV

Course Code 18CSL47

CIE Marks 40

Number of Contact Hours/Week 0:2:2

SEE Marks 60

Total Number of Lab Contact Hours 36

Exam Hours 03



Experiments 2 B

Write a Java class called Customer to store their name and date_of_birth. The date_of_birth format should be dd/mm/yyyy. Write methods to read customer data as and display as using StringTokenizer class considering the delimiter character as “/”.



Advertisement

Advertisement

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
//package twoB;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Customer {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String name;
		System.out.println("Enter the Name & DOB in the Format <name,dd/mm/yyyy>");
		name=scan.next();
		StringTokenizer st = new StringTokenizer(name,"/");
		int count=st.countTokens();
		for(int i=1;i<=count&&st.hasMoreTokens();i++)
		{
			System.out.print(st.nextToken());
			if(i<count)
				System.out.println(",");
		}
		scan.close();
	}
}

Advertisement

output
Fig 2.2: Output .

× Note Please Share the website link with Your Friends and known Students...

-ADMIN

× Note Page Number is specified to navigate between Pages...
T = Text book
QB = Question Bank
AS = Amswer Script


-ADMIN

Advertisement