John Delmark Aguilar

Delmark - Profiling
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 File Writer

View previous topic View next topic Go down 
AuthorMessage
dElmARk
Admin
Admin
avatar

Posts : 92
Join date : 09/04/2012

PostSubject: File Writer   Sat Feb 23, 2013 4:23 pm

Code:
import java.io.*;
import java.util.*;
public class Information
{
 public static void main(String[]ecs)throws Exception
 {
  Scanner sc = new Scanner(System.in);
  FileWriter fw = new FileWriter("info.txt",true);
  String Lname=" ", Fname = " ", Address = " ", Gender = " ";
  int Age=0;
  double Prelim, Midterm, Prefinal, Final =0.0;
  System.out.print("Enter Your Last Name: ");
  Lname=sc.nextLine();
  System.out.print("Enter Your First Name: ");
  Fname=sc.nextLine();
  System.out.print("Enter Your Address: ");
  Address=sc.nextLine();
  System.out.print("Enter Your Gender: ");
  Gender=sc.nextLine();
  System.out.print("Enter Your Age: ");
  Age=sc.nextInt();
  System.out.print("Enter Your Prelim: ");
  Prelim=sc.nextDouble();
  System.out.print("Enter Your Midterm: ");
  Midterm=sc.nextDouble();
  System.out.print("Enter Your Prefinal: ");
  Prefinal=sc.nextDouble();
  System.out.print("Enter Your Final: ");
  Final=sc.nextDouble();
  double Average =  (Prelim+Midterm+Prefinal+Final)/4;
  System.out.println("Your Average: "+Average);
  fw.write("Your Last Name is: " + Lname);
  fw.write("\r\nYour First Name is: " + Fname);
  fw.write("\r\nYour Address is: " + Address);
  fw.write("\r\nYour Gender is: " + Gender);
  fw.write("\r\nYour Age is: " + Age);
  fw.write("\r\nYour Prelim is: " + Prelim);
  fw.write("\r\nYour Midterm is: " + Midterm);
  fw.write("\r\nYour Prefinal is: " + Prefinal);
  fw.write("\r\nYour Final is: " + Final);
  fw.write("\r\nYour Average: "+Average);
  if (Average < 75){
  fw.write("\r\nYou Failed");
  System.out.println("You Failed");
  }else{
  fw.write("\r\nYou Passed");
  System.out.println("You Passed");
  }
  fw.close();
 }
}
Back to top Go down
View user profile http://delmark.meabout.com
 
File Writer
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Java Programs :: Tutorials-
Jump to: