I'm still a bit new to Java, so sorry if this is a silly question. Basically, I'm making a pizza program, so when I order with friends it calculates how much we all owe (for example, if two of us are in on a $4 pizza, we each pay $2 and add that to our own totals). I decided to make a new object type "Person" and an actual object "people". I made it an array and had each person as an index of the array. So far, I just want to make an index for each person and add a name for each. However, when my loop is first run, it skips the lines making the first index. The next ones run just fine. Any reason why and/or is my method for making this ineffective?
Main Class:
DecimalFormat f = new DecimalFormat("##.00");
Scanner scan = new Scanner(System.in);
double costItem;
int numPeopleIn;
Person[] people;
int y;
System.out.println("Welcome to Pizza Cost!\nTo start, how many people are in on this order?");
people = new Person[scan.nextInt()];
System.out.println("Type their names, pressing ENTER between names.");
for (int x = 0; x<people.length; x++) {
System.out.println("ran");
people[x] = new Person();
people[x].name = scan.nextLine();
System.out.println("hit the end");
}
Person Class:
package me.chris.pizzacost;
public class Person {
String name = "blank";
double cost;
}
Thanks so much in advance, -Chris