JAVA
There is a theory that the being taller is an advantage in a U.S. presidential election. It contains a text file with a list of all presidents and their heights, and also a starter program. The entries in the presidents_by_height.txt file have this format:
Abraham Lincoln 6 ft 4 in 193 cm
Lyndon B. Johnson 6 ft 3.5 in 192 cm
Create a project with the files and complete the
PresidentAverageHeight class to find the average height in
centimeters of all US presidents to date (or 0 if the file is
empty). Print with 2 decimal places.
You will use nextLine, split, and Integer.parseInt()
*****************presidents_by_height*******************
Abraham Lincoln 6 ft 4 in 193 cm
Lyndon B. Johnson 6 ft 3.5 in 192 cm
Donald Trump 6 ft 3 in 191 cm
Thomas Jefferson 6 ft 2.5 in 189 cm
George Washington 6 ft 2 in 188 cm
Chester A. Arthur 6 ft 2 in 188 cm
Franklin D. Roosevelt 6 ft 2 in 188 cm
George H. W. Bush 6 ft 2 in 188 cm
Bill Clinton 6 ft 2 in 188 cm
Andrew Jackson 6 ft 1 in 185 cm
Ronald Reagan 6 ft 1 in 185 cm
Barack Obama 6 ft 1 in 185 cm
James Monroe 6 ft 0 in 183 cm
John Tyler 6 ft 0 in 183 cm
James Buchanan 6 ft 0 in 183 cm
James A. Garfield 6 ft 0 in 183 cm
Warren G. Harding 6 ft 0 in 183 cm
John F. Kennedy 6 ft 0 in 183 cm
Gerald Ford 6 ft 0 in 183 cm
William Howard Taft 5 ft 11.5 in 182 cm
Herbert Hoover 5 ft 11.5 in 182 cm
George W. Bush 5 ft 11.5 in 182 cm
Grover Cleveland 5 ft 11 in 180 cm
Richard Nixon 5 ft 11 in 180 cm
Woodrow Wilson 5 ft 11 in 180 cm
Dwight D. Eisenhower 5 ft 10.5 in 179 cm
Franklin Pierce 5 ft 10 in 178 cm
Andrew Johnson 5 ft 10 in 178 cm
Theodore Roosevelt 5 ft 10 in 178 cm
Calvin Coolidge 5 ft 10 in 178 cm
Jimmy Carter 5 ft 9.5 in 177 cm
Millard Fillmore 5 ft 9 in 175 cm
Harry S. Truman 5 ft 9 in 175 cm
Rutherford B. Hayes 5 ft 8.5 in 174 cm
William Henry Harrison 5 ft 8 in 173 cm
James K. Polk 5 ft 8 in 173 cm
Zachary Taylor 5 ft 8 in 173 cm
Ulysses S. Grant 5 ft 8 in 173 cm
John Quincy Adams 5 ft 7.5 in 171 cm
John Adams 5 ft 7 in 170 cm
William McKinley 5 ft 7 in 170 cm
Benjamin Harrison 5 ft 6 in 168 cm
Martin Van Buren 5 ft 6 in 168 cm
James Madison 5 ft 4 in 163 cm
***************************************************************
JAVA Program to work on:
**************presidentAverageHeight********************
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class PresidentAverageHeight
{
public static void main(String[] args) throws
FileNotFoundException
{
File inputFile = new File("presidents_by_height.txt");
Scanner in = new Scanner(inputFile, "UTF-8");
double total = 0;
int count = 0;
while (in.hasNextLine())
{
String line = in.nextLine();
//Use split
}
//compute the average
in.close();
}
}
*********************************************************
Thumbs up will be given to the correct answer. Please don't look on another chegg answer elsewhere, as I found it to be wrong.
If you have any doubts, please give me comment...
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class PresidentAverageHeight {
public static void main(String[] args) throws FileNotFoundException {
File inputFile = new File("presidents_by_height.txt");
Scanner in = new Scanner(inputFile, "UTF-8");
double total = 0;
int count = 0;
double average;
while (in.hasNextLine()) {
String line = in.nextLine();
// Use split
String cols[] = line.split(" ");
//7th indicates height in cm
total += Integer.parseInt(cols[6]);
count++;
}
// compute the average
if(count==0){
average = 0;
}
else{
average = total / count;
}
System.out.printf("Average %.2f\n", average);
in.close();
}
}
JAVA There is a theory that the being taller is an advantage in a U.S. presidential...
PRESIDENT Reagan Taft Truman Harding Eisenhower Hoover G. W. Bush Garfield Pierce T. Roosevelt Harrison Lincoln J. Kennedy J. Adams McKinley Johnson G. H. W. Bush Cleveland Hayes Taylor HEIGHT 185 182 175 183 179 182 183 183 178 178 168 193 183 170 170 192 188 180 173 173 HEIGHT OPP 177 178 173 178 178 180 185 187 196 175 180 188 182 189 178 180 173 180 178 174 Refer to the data set of 20 randomly...
Refer to the data set of 20 randomly selected presidents given below. Treat the data as a sample and find the proportion of presidents who were taller than their opponents. Use that result to construct a 95% confidence interval estimate of the population percentage. Based on the result, does it appear that greater height is an advantage for presidential candidates? Why or why not? HEIGHT OPP 180 188 180 173 170 189 182 174 178 196 PRESIDENTI HEIGHT I 182...
Refer to the data set of 20 randomly selected presidents given below. Treat the data as a sample and find the proportion of presidents who were taller than their opponents. Use that result to construct a 95% confidence interval estimate of the population percentage. Based on the result, does it appear that greater height is an advantage for presidential candidates? Why or why not? Click the icon to view the table of heights. Construct a 95% confidence interval estimate of...
Refer to the data set of 20 randomly selected presidents given
below. Treat the data as a sample and find the proportion of
presidents who were taller than their opponents. Use that result to
construct a 95% confidence interval estimate of the population
percentage. Based on the result, does it appear that greater
height is an advantage for presidential candidates? Why or why
not?
Construct a 95% confidence interval estimate of the percentage
of presidents who were taller than their...
in python please
PROBLEM : (15 POINTS Use the file 'presidents age, txt You can download this file from D2L (Content' tab) to your lo computer This file contains the age (at the time of their inaguration) of the first 45 presidents (including repeats). Each president's name is separated from his age by a comma Write a function called getAges (). Inside this function, create a dictionary in which every key is the name, and the value is the president's...
A popular theory is that presidential candidates have an advantage if they are taller than their main opponents. Listed are heights (in centimeters) of randomly selected presidents along with the heights of their main opponents. Complete parts (a) and (b) below. Height (cm) of President Height (cm) of Main Opponent 187 179 183 178 182 167 189 176 192 194 168 186 a. Use the sample data with a 0.010.01 significance level to test the claim that for the population...
Refer to the data set of 20 randomly selected presidents given below. Treat the data as a sample and find the proportion of presidents who were taller than their opponents. Use that result to construct a 95% confidence interval estimate of the population percentage. Based on the result, does it appear that greater height is an advantage for presidential candidates? Why or why not? Click the icon to view the table of heights. Construct a 95% confidence interval estimate of...
Can you solve this in python.
Thank you
n Exercises 11 through 14, use the file Justices.txt that contains data abou Supreme Court justices, past and present as of Janua 015. Each record of the file the state from which thy ry 2 contains six fields -first name, last name, appointing president, the state from which the were appointed, year appointed, and the year the justice left the court. (For current justices the last field is set to 0.) The...
An IQ test is designed so that the mean is 100 and the standard deviation is 17 for the population of normal adults. Find the sample size necessary to estimate the mean IQ score of statistics students such that it can be said with 90% confidence that the sample mean is within 6 IQ points of the true mean. Assume that o = 17 and determine the required sample size using technology. Then determine if this is a reasonable sample...
A popular theory is that presidential candidates have an advantage if they are taller than their main opponents. Listed are heights (in centimeters) of randomly selected presidents along with the heights of their main opponents. Complete parts (a) and (b) below. Height (cm) of President 186 171 167 176 185 172 Height (cm) of Main Opponent 174 189 168 177 188 186 a. Use the sample data with a 0.01 significance level to test the claim that for the population...