answersLogoWhite

0

Write a program in java to print Capital of a State entered?

Updated: 8/18/2019
User Avatar

Superhit0

Lvl 1
14y ago

Best Answer

import java.io.*;

class StateCap

{

protected static void main()throws IOException

{

BufferedReader in=new BufferedReader(new InputStreamReader(System.in));

String s[]={"Uttar Pradesh","Maharshtra","West Bengal","Bihar","Jharkhand","Kerala","Tamil Nadu","Madhya Pradesh","Sikkim","Rajasthan"};

String c[]={"Luckhnow","Mumbai","Kolkata","Patna","Ranchi","Tiruvanthapuram","Chennai","Bhopal","Gangtok","Jaipur"};

String x;

do

{

byte a=0;

System.out.print("Enter the State's Name: ");

x=in.readLine();

for(byte i=0;i<s.length;i++)

{

if(x.equalsIgnoreCase(s[i]))

{

System.out.println("Capital: "+c[i]);

a++;

}

}

if(a==0)

System.out.println("SORRY! State not Found!");

System.out.println("Try Again");

}while(x.equalsIgnoreCase("stop")==false);

}

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in java to print Capital of a State entered?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you Write A program in c language for checking a diagonal matrix?

Write a program in c++ that take input in a integer matrix of size 4*4 and find out if the entered matrix is diagonal or not.


Write a program to enter a character and it will tell the character etered?

{char a;...cout > a;cout


Can you write a sentence using the word capital?

As a noun: The capital of New York State is Albany.As an adjective: In many states, murder is still a capital offense.


How do you write a program in C to convert capital letters into small letters?

Use the tolower() function in the C standard library.


Can program development be done by a program?

Yes and no, program development works in programming codes which are specifically made for humans to be entered, a program can write these programming codes too. The thing is, you would need to write the programming codes yourself before the program can use it in program development. If a program could invent the wheel, then you still need to invent that wheel before the program can. Or atleast until the thinking of the human brain can be translated into mere programming code.


How do you write capital h a?

To write &quot;Capital H a&quot;, you would simply write the letter &quot;H&quot; followed by the lowercase letter &quot;a&quot;.


Write a program in pascal that calculates the area of a circle?

{Area s the area of cube} {Length is the length of one side of the cube} program AreaofCube; var Area,Length:real; begin write('Enter the length of cube: '); readln(Length); Area:=6*(Length*Length); writeln('The area of cube is ', Area, ' cm^2.'); end.


How to write program for secant method in mathematica?

How to write a program for secant method by mathematica


Write a program in Lex to eliminate white space and collect numbers as a token?

write a lex program to delete space from the program


How do you write Square program using vb?

write a vb program to find the magic square


Write a program to multiply 33 matrix.?

write a program to multily 3*3 matrix.


How do you write cursive capital e?

write 3 backwards