J'ai du mal à comprendre un problème d'affectation, en particulier le problème me demande de créer cinq entiers ... mais je voudrais mettre en œuvre un moyen de faire 5 ou moins, si l'utilisateur le souhaite. Comment puis-je faire ceci? Je suis désolé, je suis nouveau à Java.Comment puis-je demander à l'utilisateur de sélectionner cinq variables ou moins à définir?
package realestatepropvalue;
import java.util.Scanner;
public class RealEstatePropertyValue
{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println ("Hello friend, you will enter a series "
+ "of fields that'll calculate your Real Estate Property Value.");
System.out.print ("Please enter a Street Number ");
String streetnum = sc.next();
sc.nextLine();
System.out.println ("You entered the Street Number, " +streetnum);
System.out.print ("Please enter a Street Name ");
String streetnam = sc.nextLine();
System.out.println ("You entered the Street Name, " + streetnam + " ");
System.out.print ("Please enter the number of rooms! (Up to 5!) ");
int roomcount = sc.nextInt();
String[] places = new String[5];
for(int i = 0; i < places.length; i++) {
places[i] = "Place Number: " + i;
}
sc.nextLine();
System.out.println("You said that there were " + roomcount + " rooms!");
System.out.print ("Please enter the types of rooms (up to " +roomcount+ ") that fill up the " + roomcount + " rooms!\n"
+ "(Rooms like Living, Dining, Bedroom1-2, Kitchen, Bathroom, etc!) \n ") ;
Nous vous remercions de votre aide!
'String [] endroits = new String [roomcount] ; 'Vous devriez aussi faire une instruction if pour vérifier si' roomcount <= 5'. –