Question
Fix this Java program so that it does not show the period symbol before each value that was read in from the excel file. I
Fix this Java program so that it does not show the period symbol before each value that was read in from the excel file. I am reading in an excel file using Apache POI but the output shows a period before every value that was read in. How to remove? Please write a code to remove this and add comments so reading and understanding is easier.
package populationeval;
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Scanner;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class PopulationEval {
public static void main(String[] args) throws IOException, InvalidFormatException { File excelFile = new File("C:\Users\Assds\Documents\2017census.xlsx"); FileInputStream fis = new FileInputStream(excelFile); XSSFWorkbook myWorkbook = new XSSFWorkbook(excelFile); XSSFSheet mySheet = myWorkbook.getSheetAt(0); Iterator
break; case Cell.CELL_TYPE_STRING: String stringValue = cell.getStringCellValue(); System.out.print(stringValue ); if(selectedRow >= 3 && selectedColumn == 1) { geographicName = stringValue; } if(selectedColumn != 1 && selectedRow >= 3) { yearlyData.add(stringValue); } break; } selectedColumn++; } if(!geographicName.isEmpty()) { GeographicArea.put(geographicName, yearlyData); } System.out.println(); selectedRow++; } //System.out.println(GeographicArea); fis.close(); Scanner input = new Scanner(System.in); System.out.println("Which state would you like to view data for from 2010 to 2017? Use proper spelling."); String user = input.nextLine(); if(GeographicArea.containsKey(user)) { System.out.println("The data from year 2010 to 2017 for " + user + " is: " + GeographicArea.get(user)); } }
}
The picture shows what happens when I run my program. I need to get rid of the period symbols. Thanks.
Tur table with row headers in columm A and colmn headers in rous 3 throngh 4. (leading dots indicate sub-parts) .nlabama Alaska .Arizona Arkansas California .Colorado connecticut Delaware District of Columbia Florida Georgia iawaii Idaho llinoi:s Indiana Iowa Kentucky .Louisiana Maine Maryland .Massachusetts Michigan Minnesota .Mississippi Missouri Tur table with row headers in columm A and colmn headers in rous 3 throngh 4. (leading dots indicate sub-parts) .nlabama Alaska .Arizona Arkansas California .Colorado connecticut Delaware District of Columbia Florida Georgia iawaii Idaho llinoi:s Indiana Iowa Kentucky .Louisiana Maine Maryland .Massachusetts Michigan Minnesota .Mississippi Missouri
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started