Question

Problem Statement You are to create a project for a census bureau to obtain and analyze...

Problem Statement

You are to create a project for a census bureau to obtain and analyze household income survey data within the Cincinnati area (including Northern Ky).

Data Collected:

• Date of the survey – required (use datepicker), must be a valid date

• County and State (1 input only) they reside in - required

o Hamilton, Oh

o Butler, Oh

o Boone, Ky

o Kenton, Ky

• Number in Household – required, must be numeric, must be greater than 0

• The household yearly income – required, must be numeric, must be greater than 0.

Events:

​There should be the following navigation on the screen:

1. Submit:

a. This event will validate all data and save the data to the necessary arrays for processing.

2. Reset:

a. Will reset all fields for the next set of inputs.

3. Total Households Surveyed:

a. This event will process the arrays and display the total households surveyed by state and then by county via HTML (see below for example).

4. Average Household Income:

a. This event will process the arrays and display the average household income by state and then by county via HTML (see below for example).

5. Percentage Below Poverty:

a. This event will process the arrays and display the Percentage Below Poverty for each state and their counties via HTML. Poverty is based on the table below.

6. HOME:

a. This will take you back to the input screen for future input of census data.

Instructions:

1) Use good naming conventions on all controls, variables, etc.

2) Note: To complete this project you will string manipulation techniques to separate the county and state. You will also use a session variable to keep track of your amount of entries in your array. And you will use session arrays to hold all of the data entered.

3) All survey data from form must be saved to parallel arrays (county, state, household number, and household income) a total of 4) upon submission of each census. No calculations should be done until the following buttons are clicks.

a. When the user clicks the button “Total Households Surveyed”, do the necessary array processing and display in HTML the Total Households Surveyed by State and by county for all that were surveyed (see below for example).

b. When the user clicks the button “Average Household Income”, do the necessary array processing and display in HTML the Average Household Income by State and by county for all that were surveyed (see below for example).

c. When the user clicks the button “Percentage Below Poverty”, do the necessary array processing and display in HTML the Percentage Below Poverty by State and by county for all that were surveyed (see below for example).

Average Household Income

Ohio: ​$30,000

Hamilton: ​$40,000

Butler: ​$20,000

Kentucky:​$35,000

Boone:​$40,000

Kenton:​$35,000

Basis of Poverty:

• Household of 1 and less than $12,000

• Household of 2 and less than $18,000

• Household of 3 and less than $25,000

• Household of 4 and less than $30,000

• Household of 5 or more and less than $40,000

***** UPDATE *******

The main form would be an HTML document (index.html) where the Date of Survey, County, State, Household Amount Number and Income would be filled out. On the HTML form there are four fields. Date of Survey, County and State, Household Amount Number and Income. The County and State would be separated by string manipulation.

When the user clicks Submit, the fields would be validated, County and State would be separated by string manipulation, and session arrays would be created for each field within a .php page (census_process.php). Then the user would be redirected back to the form to enter another survey.

After all surveys have been added, the user should be able to click 1 of 3 links and be navigated to other .php pages to get either the total number of surveys performed, the average household income per county and state, or average number of people per household.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//index.html

<html>

<head>

    <title>

        Census

    </title>

    <style type="text/css">

        a {

            padding: 10px;

            font-weight: 600;

        }

    </style>

</head>

<body>

    <div>

        <a href="index.html">Home</a>

        <a href="total_surveyed.php">Total Households Surveyed</a>

        <a href="avg_income.php">Average Household Income</a>

        <a href="perc_below_poverty.php">Percentage Below Poverty</a>

    </div>

    <form action="census_process.php" method="POST">

        <label>Date of Survey:</label>

        <input type="date" name="surveyDate" value="2019-01-01" required />

        <br />

        <label>Country and State: </label>

        <select name="countryState" required>

            <option>Hamilton, Oh</option>

            <option>Butler, Oh</option>

            <option>Boone, Ky</option>

            <option>Kenton, Ky</option>

        </select>

        <br />

        <label>Number in Household: </label>

        <input type="number" name="noOfHouseHold" min="1" required />

        <br />

        <label>The household yearly income: </label>

        <input type="number" name="yearlyIncome" min="1" required />

        <br />

        <input type="submit" value="Submit" />

        <input type="reset" value="Reset" />

    </form>

</body>

</html>

//head.php

<a href="index.html">Home</a>

<br/>

<?php

session_start();

if(!isset($_SESSION['country']) || !isset($_SESSION['state']) || !isset($_SESSION['noOfHousehold']) || !isset($_SESSION['yearlyIncome'])){

    return;

}

//census_process.php

<?php

session_start();

if(!isset($_SESSION['noOfSurveys'])){

    $_SESSION['noOfSurveys']=0;

}

$index = $_SESSION['noOfSurveys'];

$surveyDate = $_POST['surveyDate'];

$countryState = explode(",", $_POST['countryState']);

$noOfHousehold = $_POST['noOfHouseHold'];

$yearlyIncome = $_POST['yearlyIncome'];

if(!isset($_SESSION['country'])){

    $_SESSION['country'] = array();

}

$_SESSION['country'][$index] = $countryState[1];

if(!isset($_SESSION['state'])){

    $_SESSION['state'] = array();

}

$_SESSION['state'][$index] = $countryState[0];

if(!isset($_SESSION['noOfHousehold'])){

    $_SESSION['noOfHousehold'] = array();

}

$_SESSION['noOfHousehold'][$index] = $noOfHousehold;

if(!isset($_SESSION['yearlyIncome'])){

    $_SESSION['yearlyIncome'] = array();

}

$_SESSION['yearlyIncome'][$index] = $yearlyIncome;

$_SESSION['noOfSurveys']++;

header("Location: index.html");

//total_surveyed.php

<?php

include_once("head.php");

$noOfSurveysByState = array_count_values($_SESSION['state']);

$noOfSurveysByCountry = array_count_values($_SESSION['country']);

echo "No of survery by State: <br/>";

foreach ($noOfSurveysByState as $key => $value) {

    echo $key.": ".$value."<br/>";

}

echo "<br/><br/>No of survery by Country: <br/>";

foreach ($noOfSurveysByCountry as $key => $value) {

    echo $key.": ".$value."<br/>";

}

//avg_income.php

<?php

include_once('head.php');

$incomeByState = array();

$incomeByCountry = array();

for($i=0;$i<$_SESSION['noOfSurveys'];$i++){

    if(!array_key_exists($_SESSION['country'][$i], $incomeByCountry)){

        $incomeByCountry[$_SESSION['country'][$i]] = array();

    }

    if(!array_key_exists($_SESSION['state'][$i], $incomeByState)){

        $incomeByState[$_SESSION['state'][$i]] = array();

    }

    array_push($incomeByCountry[$_SESSION['country'][$i]], $_SESSION['yearlyIncome'][$i]);

    array_push($incomeByState[$_SESSION['state'][$i]], $_SESSION['yearlyIncome'][$i]);

}

echo "Average household income by Country: <br/>";

foreach($incomeByCountry as $key => $value){

    $avg = array_sum($value) / count($value);

    echo $key.": $".$avg."<br/>";

}

echo "<br/> Average household income by State: <br/>";

foreach($incomeByState as $key => $value){

    $avg = array_sum($value) / count($value);

    echo $key.": $".$avg."<br/>";

}

Add a comment
Know the answer?
Add Answer to:
Problem Statement You are to create a project for a census bureau to obtain and analyze...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT