pin plaza
Apprentice
ILL VOUCH IF U HELP!
I AM A NEWB WITH JAVA AND I MAKE VERY SMALL MISTAKES
look out
my code is supposed to make a file and write the inputs on it...
and for some reason it wont can u check my code?
import java.util.Scanner;
import java.io.*;
public class PizzaOrderingMachine {
public static void main(String args[]) {
//Declaring Variables
String firstName; // Contains the first name of the user
String lastName; // Contains the last name of the user
String streetAddress; // Containd the street address of the user
String phoneNumber; // Contains the phone number of the user
String extentionNumber; // Contains the Extention Number or the Buzzer Number of the User
Scanner input = new Scanner(System.in); // Making a new scanner object.
// Making a new file.
File textFile = new File ("C:\\UserInfo.txt"); // Making a file
FileWriter out;
BufferedWriter writeFile;
try {
textFile.createNewFile();
out = new FileWriter(textFile);
writeFile = new BufferedWriter(out);
// Asking the user for their first name.
System.out.println("Please enter your first name.");
firstName = input.nextLine();
// Asking the user for their last name.
System.out.println("Please enter your last name.");
lastName = input.nextLine();
// Asking the user for their street address.
System.out.println("Please enter your street address.");
streetAddress = input.nextLine();
// Asking the user for their phone number.
System.out.println("Please enter your phone number.");
phoneNumber = input.nextLine();
// Asking the user for their extention number.
System.out.println("Please enter your extention number.");
extentionNumber = input.nextLine();
writeFile.write(firstName);
writeFile.write(" ");
writeFile.write(lastName);
writeFile.newLine();
writeFile.write(phoneNumber);
writeFile.write(extentionNumber);
writeFile.newLine();
writeFile.write(streetAddress);
} catch (IOException e){
System.out.println("IOException: " + e.getMessage()); // Will output the message if IOExeption is found.
}
}
}
I AM A NEWB WITH JAVA AND I MAKE VERY SMALL MISTAKES
look out
my code is supposed to make a file and write the inputs on it...
and for some reason it wont can u check my code?
import java.util.Scanner;
import java.io.*;
public class PizzaOrderingMachine {
public static void main(String args[]) {
//Declaring Variables
String firstName; // Contains the first name of the user
String lastName; // Contains the last name of the user
String streetAddress; // Containd the street address of the user
String phoneNumber; // Contains the phone number of the user
String extentionNumber; // Contains the Extention Number or the Buzzer Number of the User
Scanner input = new Scanner(System.in); // Making a new scanner object.
// Making a new file.
File textFile = new File ("C:\\UserInfo.txt"); // Making a file
FileWriter out;
BufferedWriter writeFile;
try {
textFile.createNewFile();
out = new FileWriter(textFile);
writeFile = new BufferedWriter(out);
// Asking the user for their first name.
System.out.println("Please enter your first name.");
firstName = input.nextLine();
// Asking the user for their last name.
System.out.println("Please enter your last name.");
lastName = input.nextLine();
// Asking the user for their street address.
System.out.println("Please enter your street address.");
streetAddress = input.nextLine();
// Asking the user for their phone number.
System.out.println("Please enter your phone number.");
phoneNumber = input.nextLine();
// Asking the user for their extention number.
System.out.println("Please enter your extention number.");
extentionNumber = input.nextLine();
writeFile.write(firstName);
writeFile.write(" ");
writeFile.write(lastName);
writeFile.newLine();
writeFile.write(phoneNumber);
writeFile.write(extentionNumber);
writeFile.newLine();
writeFile.write(streetAddress);
} catch (IOException e){
System.out.println("IOException: " + e.getMessage()); // Will output the message if IOExeption is found.
}
}
}

