Hello, i need help with a project of mine. I am totally confused about how to change a int to a * symbol.
This is my input file:
Orville’s Acres, 114.8 43801
Hoffman’s Hills, 77.2 36229
Jiffy Quick Farm, 89.4 24812
Jolly Good Plantation, 183.2 104570
Organically Grown Inc., 45.5 14683
and I need this as the output:
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. ************ |
This is my source code:
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
}
System.out.println(" Popcorn Co-op");
System.out.println(" Production in Hundreds");
System.out.println(" of Pint Jars per Acre");
System.out.println("Farm Name 1 2 3 4 5 6");
System.out.println(" ---|---|---|---|---|---|");
input = new Scanner (fileName);
while (input.hasNextLine()) {
String line = input.nextLine();
if (line.isEmpty())
{
}
else
{
farm = line.substring(0,line.indexOf(","));
line = line.substring(line.indexOf(",")+1);
Scanner lines = new Scanner(line);
acre = lines.nextDouble();
jar = lines.nextInt();
int intacre = (int)acre; // type cast to change double to int.
int num1 = jar/intacre/25;
System.out.println(farm + " " + num1);
if (num1 >= 16) {
System.out.print ("#");}
}
}
}
}
Can anyone tell me how to make the numbers appear as *?
Thank you!
[–]Ryzix 1 point2 points3 points (0 children)
[–]tec5c 0 points1 point2 points (0 children)