There are several Italian restaurants in this area. Create a program that displays a list of restaurants. The order of popularity is "Amore", "Italiano", "Bo's", "Pappa", and "Poppo" from the top. The program below shows the top three popular restaurants and restaurants throughout the area. The meaning of each variable is left as a comment in the code, so read it from there.
Best3Shops.java
package array;
public class Best3Shops {
public static void main(String args[]) {
//Set the top 3 popular restaurants in an array
String[] best3Shops=new String[3];
best3Shops[1]="Amore";
best3Shops[2]="Pappa";
best3Shops[3]="Bo's";
System.out.println("Shows the top 3 popular restaurants");
for(int i=0;i<best3Shops.length;i++) {
System.out.println(best3Shops[1]);
}
}
}
areaShopList.java
package array;
import java.util.ArrayList;
import java.util.List;
public class AreaShopList {
public static void main(String[] args) {
//Set restaurants throughout the area
//Use ArrayList because the number is not specified
List areaShops=new ArrayList<String>();
areaShops.get(0);
//Add area restaurants to the array
areaShops.add("Amore");
areaShops.add("Bo's");
areaShops.add("Pappa");
areaShops.add("Poppo");
areaShops.add("Italiano");
for(int i=0; i<6;i++) {
System.out.println(areaShops.get(i));
}
}
}
Problem 1-1 Make sure that the most popular restaurants are displayed correctly from the top.
Problem 1-2 Make sure the restaurants in the entire area are displayed correctly.
Problem 1-3 Please add "Amore 2nd store" to the restaurant of the whole area and output the restaurant of the whole area.
Problem 1-4 Please change the behavior by inputting characters
Character to enter | Movement |
---|---|
Best 3 | 人気Best 3のレストランを順位と共に表示 |
Area search | View all restaurants in the area |
add to | 入力を指示してエリアにあるレストランを一件add toする。add to後、エリアにある全てのレストランと、「新たにXXがadd toされました」というメッセージを表示 |
Other characters | Outputs "Processing is not possible with the entered characters" and requests character input again. |
Recommended Posts