import java.io.*;
import java.util.Scanner;
public class Popcorn
{
public static void main(String [] args) throws IOException{
String farm ;
double acre = 0;
int jar = 0;
Scanner input = new Scanner (System.in);
System.out.print("Input the file name with .txt extention : "); // for the user to input the file name with .txt extesion.
File fileName = new File(input.nextLine());// Gets the File Name
while(!fileName.exists()) { // It will ask the user to enter the file name again if it is not in directory.
// Prompts for input file name
System.out.print("The file is not in this directory. Please re-enter the file name: ");
fileName = new File(input.nextLine()); //Gets the File Name
input = new Scanner (System.in); // Constructs File object
}
Это входной файл:Как преобразовать номер ответа в строку звездочками
Orville's Acres, 114.8 43801
Hoffman's Hills, 77.2 36229
Jiffy Quick Farm, 89.4 24812
Jolly Good Plantation, 183.2 104570
Вот как это следует выводить:
Popcorn Co-op
Production in Hundreds
of Pint Jars per Acre
Farm Name 1 2 3 4 5 6
---|---|---|---|---|---|
Orville's Acres ****************|
Hoffman's Hills ****************#***
Jiffy Quick Farm ************ |
Jolly Good Plantation ****************#***
Organically Grown Inc. ************ |
Это то, что я получаю когда я запускаю программу:
Popcorn Co-op
Production in Hundreds
of Pint Jars per Acre
Farm Name 1 2 3 4 5 6
---|---|---|---|---|---|
Orville's Acres 15
Hoffman's Hills 18
#Jiffy Quick Farm 11
Jolly Good Plantation 22
#>
Если кто-либо может связаться l me, как преобразовать числа, которые я получаю к звездам, я был бы признателен.
Традиционно, вы хотите использовать цикл. – SimplyPanda
Код, который вы предоставили, никогда не выводит то, что вы говорите, это уже делает. Обновите код до того, что у вас есть. – gfelisberto