how to difficulty in removing error 2 Answer(s) 3 years and 5 months ago
Posted in : Java Beginners
View Answers
December 14, 2009 at 4:30 PM
Hi Friend,
Try the following code:
import java.io.*; import java.util.*; import java.util.regex.*; class skeleton{ public static void main(String[]args)throws Exception{ Scanner input=new Scanner(System.in); boolean quit = false; int p=0; System.out.println("1-create"); System.out.println("2-reading"); System.out.println("3-backup"); System.out.println("4-modifydata"); System.out.println("5-delete"); System.out.println("6-instruction"); System.out.println("7-exit");
do{ System.out.println(""); System.out.println("choose option from 1to7"); System.out.println(""); p=input.nextInt(); switch(p){ case 1: System.out.println("Enter student's name: "); String name=input.next(); System.out.println("Enter student's class: "); int cl=input.nextInt(); System.out.println("Enter the student's division"); String div=input.next(); System.out.println("Enter the students roll No"); int roll=input.nextInt(); System.out.println("Enter the students marks in English Literature"); int lit=input.nextInt(); System.out.println("Enter the students marks in English Language"); int lang=input.nextInt(); System.out.println("Enter the students marks in Hindi"); int hin=input.nextInt(); System.out.println("Enter the students marks in History"); int hist=input.nextInt(); System.out.println("Enter the students marks in Geogrophy"); int geog=input.nextInt(); System.out.println("Enter the students marks in Mathematics"); int maths=input.nextInt(); System.out.println("Enter the students marks in Physics"); int phy=input.nextInt(); System.out.println("Enter the students marks in Chemistry"); int chem=input.nextInt(); System.out.println("Enter the students marks in Biology"); int bio=input.nextInt(); System.out.println("Enter the students marks in Enviromental Education"); int eve=input.nextInt(); System.out.println("Enter the students marks in Computer Application"); int ctsa=input.nextInt(); int total=lit+lang+hin+hist+geog+maths+phy+chem+bio+eve+ctsa; File file = new File("C:\\report.dat"); FileWriter fw = new FileWriter(file,true); BufferedWriter out = new BufferedWriter(fw); out.write(name+" "+Integer.toString(cl)+" "+div+" "+Integer.toString(roll)+" "+Integer.toString(lit)+" "+Integer.toString(lang)+" "+Integer.toString(hin)+" "+Integer.toString(geog)+" "+Integer.toString(maths)+" "+Integer.toString(phy)+" "+Integer.toString(chem)+" "+Integer.toString(bio)+" "+Integer.toString(eve)+" "+Integer.toString(ctsa)+"Totals is:"+Integer.toString(total)); out.newLine(); out.close(); break;
December 14, 2009 at 4:31 PM
continue..
case 2: FileInputStream fstream = new FileInputStream("C:\\report.dat"); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null) { System.out.println (strLine); } in.close(); break; case 3: BufferedReader reader = new BufferedReader(new FileReader("c:\\report.dat")); Pattern pat = Pattern.compile(",(\".+?\")"); String line=null; while ((line=reader.readLine())!=null){ Matcher matcher = pat.matcher(line); StringBuffer sb = new StringBuffer(); while (matcher.find()){ matcher.appendReplacement(sb,","+matcher.group(1).replaceAll(",","&comm")); } matcher.appendTail(sb); String[] fields = sb.toString().split(","); for (int i=0;i<fields.length;i++){ String s = fields[i]!=null ? fields[i].replaceAll("&comm",",") : ""; FileWriter writer = new FileWriter("backup.dat",true); BufferedWriter output = new BufferedWriter(writer); output.write(s+","); output.newLine(); output.close(); } } break; case 4: break; case 5: break; case 6: break; case 7: quit=true; } } while (!quit); } }
Thanks
Related Pages:
how to difficulty in removing error - Java Beginners how to difficulty in removing error import java.io.*;
class skeleton
{
public static void main()throws IOExeception
{
DataInputStream data=new DataInputSTream(System.in);
int p=0;
//loop variables to read cell value
Programming Difficulty - Java Beginners
are the student's scores on three exams. How to write a program that will read... exception if any
System.err.println("Error: " + e.getMessage
Removing existing cookie in jsp Removing existing cookie in jsp How remove existing cookie in jsp ?
If you want to remove an existing cookie, you can use the method setMaxAge() of that cookie object to set its timeout to zero.Example
<%@page
Regular Expression for removing XML Tags
Regular Expression for removing XML Tags Hi,
Good Afternoon.I want a Regular expression in java which is removing the XML Tags in the specified Text String like,
String txt="<Hello>How are you"; I want output of this txt
error!!!!!!!!! error!!!!!!!!! st=con.createStatement();
int a=Integer.parseInt(txttrno.getText());
String b=txttname.getText... help me in removing errors in the above line
error!!!!!!!!! error!!!!!!!!! st=con.createStatement();
int a=Integer.parseInt(txttrno.getText());
String b=txttname.getText... help me in removing errors in the above line
error!!!!!!!!! error!!!!!!!!! st=con.createStatement();
int a=Integer.parseInt(txttrno.getText());
String b=txttname.getText... help me in removing errors in the above line
Difficulty in plugging log4J with Hibernate. Difficulty in plugging log4J with Hibernate. I am using Hibernate 3.6.
Followed your all instruction of plugging log4j with my hibernate code...
log4j.properties in the class path.
log4j.jar in the class path
Still when I run
error
error java.lang.unsupportedclassversionerror:bad major version at offset 6
how to solve this????
Hi,
Please check the version of framework used and also the JDK version.
This type error also comes when java file
error
(DriverManager.java:171)
at excelDB.ExcelDB.main(Excel_DB.java:210)
how to solve dis error
Error
Error Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance.
package...;");
// ERROR
out.println(" var pattern
Error
Error Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance.
package...;");
// ERROR
out.println(" var pattern
Error
Error Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance.
package...;");
// ERROR
out.println(" var pattern = /^\d{3,5
Error
Error Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance.
package...;");
// ERROR
out.println(" var pattern
error
error how do i set jdk home path in jcreator le
Removing duplicate white spaces from a String Removing duplicate white spaces from a String
In this section, you will learn how... of removing all the
duplicate white spaces from the given string.
Program Result
Removing a Column from a JTable Removing a Column from a JTable
In this section, you will learn how to remove a column
from a JTable component that uses the table model. Removing a column from
a JTable
Removing the Title Bar of a Frame Removing the Title Bar of a Frame
In this section, you will learn how to remove the title bar of a frame
or window in java. That means show the frame or window without
Removing characters from a string Removing characters from a string Removing characters from a string
Example:
public class CharReplace{
public static void main(String []args){
String str="Hello 123.you are At 3456";
String
Removing the title bar of the Frame in Java Removing the title bar of the Frame in Java
Introducion
Here, you will learn how to display the frame or window without title bar in
java. This type
how to resolve this JDBC Error? how to resolve this JDBC Error? i am trying to Exceute this code:
import java.sql.DatabaseMetaData;
import java.sql.Connection;
import...
but when i am executing this code i am getting this Error:
Exception in thread
please how fix this error? How to Fix Error
for this following code :
$var1 = $_POST["name"];
$var2 = $_POST["id"];
$st = 'INSERT INTO USERNAME(id,name) VALUES(:var1,:var2)';
$query = ociparse($con,$st);
OCIBindByName($st ,':va1',$var1
Permgen error
Permgen error hi how can i solve permgen error
installation error
installation error hi, m getting an error like "
semicolon found in the selected path".how to resolve this error? during installation of jdk 1.6
How to trap Trigger Error - SQL How to trap Trigger Error Hi Guys,
Can you please help with my problem?..
Is there a way in where I can trap all SQL error and place it under... error_log (
timestamp DATETIME,
username NVARCHAR(30
Wrapping, replacing, and removing content
Wrapping, replacing, and removing content
Wrapping, replacing, and removing content
The JQuery provide efficient ways for wrapping, replacing, and removing
404 error
into jboss->server-> default->deploy folder it doesn't shows any error. but when i run this application by using localhost:8080/webapp ,it shows 404 errorhow should i slove this error
Error on example Error on example When I execute this program,it is throwing ArrayIndexOutOfBound exception. How can I solve this.
Post your code
404 error
404 error i have 404 error in my addition programe of servlet how should i solve this.
i'm using netbean on glassfish server
404 error
404 error i have 404 error in my addition programe of servlet how should i solve this.
i'm using netbean on glassfish server
How to Solve the Syntax Error in java?? How to Solve the Syntax Error in java?? Syntax error in java?
i have tried this program its showing error like this in Eclipse "Syntax error... of the program "objectname.i"
What is the reason for this error??How to access the variable
still error
..... can smone help me in removing errors from ds...........
Hi Friend
JFREE error
JFREE error hi.........
the code for making chart is: WHICH IS GIVING THE ERROR
import org.jfree.chart.*;
import org.jfree.data.category.... THE RECTANGLEINSETS NA THEN WHY ITS GIVING ME THE ERROR.
tHE IMPORT FILE
Removing duplicate white spaces from a text file Removing duplicate white spaces from a text file
This section shows you how to remove all... as follows
for the best illustration for how to remove all duplicate white
Determine Average by removing Largest and Smallest Number
Determine Average by removing Largest and Smallest Number
In this section, you will learn how to remove largest and smallest number from the 10 numbers and then determine the average. For this, an user is allowed to input 10 numbers
error come error come com.techi.bean.Employee cannot be cast to [Ljava.lang.Object;...
i display the data action to jsp using set list atribute on action... form
like
ID: com.techi.bean.Employee@bf9ab9
please tell me how i find
Servlet error
Servlet error In netbeans6.9 how can we deploy our servlet
in my project i design servlet to receive the data through html pages
and design database also but unable to do with xml files what we can change in sun-web.xml
validation error value is not valid
validation error value is not valid How to recognize and throw error like "validation error value is not valid
Removing a Row from a JTable Removing a Row from a JTable
 ... the JTable. For removing the data of row from JTable, you will
remove it from... data by using
the DefaultTableModel that helps us for removing the data of row
pointer error java
pointer error java How to catch null pointer errors in java if the if(value != null) or null
error occured in following page ... how to resolve it? error occured in following page ... how to resolve it? // to convert... error ....wht i shud do???????? i m java beginner so plz explain in smooth way....
error is::::
Exception in thread "main" java.lang.IllegalArgumentException
How to create and use custom error page in jsp How to create and use custom error page in jsp
This is detailed java code how to create and use custom
error page in
jsp and display an error message.
Before run