In my program im getting class or interface expected ..its a small basic prog..plz help me to solve it?
significance java.io.*;
training Br1
open public static emptiness main (String args)throws IOException
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Process.out.println(“Enter figure, ‘q’ to help Quit”);
do
char c=br.readLine();
Process.out.println(c);
while(c! =’q’);
This can be happening when you provided COUPLE OF extra braces when they get home of the actual program
Other errors that happen to be present usually are
JUST ONE.char c=br.readLine();
readLine() income String, not only a character.
TWO.String d (In your program char c) need to be declared just before do, Since you are utilizing it in though, its scope need to be global.Where by in your program the actual scope is actually local
3.while(c! =’q’) need to be changed for you to while(c! =”q”) since c may be a string
5.Its better to work with equalsIgnoreCase() in comparison with “! =”
Revised Code
significance java.io.*;
significance java.util.*;
training Br1
open public static emptiness main (String args)throws IOException
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Process.out.println(“Enter figure, ‘q’ to help Quit”);
String c;
do
c=br.readLine();
Process.out.println(c);
while(! d.equalsIgnoreCase(“q”));
Thanks, hope this helps
import coffee beans.io.*;
training Br1
open public static emptiness main(String args) tosses IOException
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Process.out.println(“Enter figure, ‘q’ to help quit”);
char ch;
do
ch=(char)br.read();
Process.out.println(c);
while(c! =’q’);
Leave a Reply
You must be logged in to post a comment.