Questions
# Write a function called `get_state_data` that allows you to specify a state, # then saves...

# Write a function called `get_state_data` that allows you to specify a state,
# then saves a .csv file (`STATE_data.csv`) with observations from that state
# This includes data about the state, as well as the counties in the state
# You should use the full any.drinking dataset in this function (not just 2012)

# Demonstrate that you function works by passing "Utah" to the function
state_Utah <- get_state_data(Utah)

############################ Binge drinking Dataset ############################

# In this section, you will ask a variety of questions regarding the
# `binge_drinking.csv` dataset. More specifically, you will analyze a subset of
# the observations of *just the counties* (exclude state/national estimates!).
# You will store your answers in a *named list*, and at the end of the section,
# Convert that list to a data frame, and write the data frame to a .csv file.
# Pay close attention to the *names* to be used in the list.


# Create a dataframe with only the county level observations from the
# `binge_driking.csv` dataset. You should (again) think of Washington D.C. as
# a state, and therefore *exclude it here*.
# However, you should include "county-like" areas such as parishes and boroughs
county_data <- binge.drinking.csv %>% distinct(state)

# Create an empty list in which to store answers to the questions below.


# What is the average county level of binge drinking in 2012 for both sexes?
# Store the number in your list as `avg_both_sexes`.


# What is the name of the county with the largest increase in male binge
# drinking between 2002 and 2012?
# Store the county name in your list as `largest_male_increase`.


# How many counties experienced an increase in male binge drinking between
# 2002 and 2012?
# Store the number in your list as `num_male_increase`.


# What fraction of counties experienced an increase in male binge drinking
# between 2002 and 2012?
# Store the fraction (num/total) in your list as `frac_male_increase`.

  
# How many counties experienced an increase in female binge drinking between
# 2002 and 2012?
# Store the number in your list as `num_female_increase`.


# What fraction of counties experienced an increase in female binge drinking
# between 2002 and 2012?
# Store the fraction (num/total) in your list as `frac_female_increase`.


# How many counties experienced a rise in female binge drinking *and*
# a decline in male binge drinking?
# Store the number in your list as `num_f_increase_m_decrease`.

# Convert your list to a data frame, and write the results
# to the file `binge_info.csv`

# The next questions return *data frames as results*:

# What is the *minimum* level of binge drinking in each state in 2012 for
# both sexes (across the counties)? Your answer should contain roughly 50 values
# (one for each state), unless there are two counties in a state with the
# same value. Your answer should be a *dataframe* with the location, state, and
# 2012 binge drinking rate. Write this to a file called `min_binge.csv`.


# What is the *maximum* level of binge drinking in each state in 2012 for
# both sexes (across the counties)? Your answer should contain roughly 50 values
# (one for each state), unless there are two counties in a state with the
# same value. Your answer should be a *dataframe* with the location, state, and
# 2012 binge drinking rate. Write this to a file called `max_binge.csv`.

  
################################# Joining Data #################################
# You'll often have to join different datasets together in order to ask more
# involved questions of your dataset. In order to join our datasets together,
# you'll have to rename their columns to differentiate them.


# First, rename all prevalence columns in the any_drinking dataset to the
# have prefix "any_" (i.e., `males_2002` should now be `any_males_2002`)
# Hint: you can get (and set!) column names using the colnames function.
# This may take multiple lines of code.


# Then, rename all prevalence columns in the binge_drinking dataset to the have
# the prefix "binge_" (i.e., `males_2002` should now be `binge_males_2002`)
# This may take multiple lines of code.


# Then, create a dataframe by joining together the both datasets.
# Think carefully about the *type* of join you want to do, and what the
# *identifying columns* are. You will use this (joined) data to answer the
# questions below.


# Create a column `diff_2012` storing the difference between `any` and `binge`
# drinking for both sexes in 2012


# Which location has the greatest *absolute* difference between `any` and
# `binge` drinking? Your answer should be a one row data frame with the state,
# location, and column of interest (diff_2012).
# Write this dataframe to `biggest_abs_diff_2012.csv`.


# Which location has the smallest *absolute* difference between `any` and
# `binge` drinking? Your answer should be a one row data frame with the state,
# location, and column of interest (diff_2012).
# Write this dataframe to `smallest_abs_diff_2012.csv`.

############## Write a function to ask your own question(s) ####################
# Even in an entry level data analyst role, people are expected to come up with
# their own questions of interest (not just answer the questions that other
# people have). For this section, you should *write a function* that allows you
# to ask the same question on different subsets of data. For example, you may
# want to ask about the highest/lowest drinking level given a state or year.
# The purpose of your function should be evident given the input parameters and
# function name. After writing your function, *demonstrate* that the function
# works by passing in different parameters to your function.


################################### Challenge ##################################

# Using your function from part 1 that wrote a .csv file given a state name,
# write a separate file for each of the 51 states (including Washington D.C.)
# The challenge is to do this in a *single line of (very concise) code*


# Write a function that allows you to pass in a *dataframe* (i.e., in the format
# of binge_drinking or any_drinking) *year*, and *state* of interest. The
# function should saves a .csv file with observations from that state's counties
# (and the state itself). It should only write the columns `state`, `location`,
# and data from the specified year. Before writing the .csv file, you should
# *sort* the data.frame in descending order by the both_sexes drinking rate in
# the specified year. The file name should have the format:
# `DRINKING_STATE_YEAR.csv` (i.e. `any_Utah_2005.csv`).
# To write this function, you will either have to use a combination of dplyr
# and base R, or confront how dplyr uses *non-standard evaluation*
# Hint: https://github.com/tidyverse/dplyr/blob/34423af89703b0772d59edcd0f3485295b629ab0/vignettes/nse.Rmd
# Hint: https://www.r-bloggers.com/non-standard-evaluation-and-standard-evaluation-in-dplyr/


# Create the file `binge_Colorado_2007.csv` using your function.

In: Computer Science

Create a UI that has a field in which to enter text, a field to display...

Create a UI that has a field in which to enter text, a field to display read-only text and a button. When the button is pressed, take the value of the text box and try to create a month object. If a number was entered, use the constructor that accepts an integer. If alphabetic characters were entered, use the constructor that accepts a string. If nothing is entered, use the no-argument constructor. If a valid month object is created, use the toString function on the month object to display info about the month. Otherwise, display an appropriate error message.

Create a UI with two drop-down lists, a button, and a field to display read-only text. One drop-down has the values 1-12. The other has the names of the months. When the button is pressed, create two-month objects using the appropriate constructors, then display if the months are equal, if month 1 > month 2 or if month 2 > month 1.

TWO SEPERATE USER INTERFACES.

THIS IS TO BE DONE USING JAVA

In: Computer Science

Prepare functional specifications for my barbershop company the Web and the internet. Include links to and...

Prepare functional specifications for my barbershop company the Web and the internet. Include links to and from other sites in your design.

In: Computer Science

Implement a simple banking system in Java. Your application should demonstrate the following. Upon running the...

Implement a simple banking system in Java. Your application should demonstrate the following. Upon running the java code, first the application should welcome the user, then ask the user to give one of the options:

1) display the balance summary,

2) withdraw money, or

3) deposit money.

Based on the options your code should perform the following operations such as

1) read the transaction details from a file and display them on the screen.

2) ask the user to enter the amount he wants to withdraw and debit the withdrawal amount from the balance amount. It has to update the file and display the transaction summary. The system should not allow an attempt to withdraw an amount greater than the balance.

3) ask the user to enter the amount he wants to deposit, credit the balance and update the file. It should display the transaction summary.

The records in the file should contain transaction number, transaction type, amount withdrawn, or amount deposited, and balance. Example:

1 Deposit 100.0$ 1100.0$

2 Withdraw 50.0$ 1050.0$

The welcome screen should look like:

Welcome to CIS-2348 Banking System!

Enter your Option in a number: 1. Display balance 2. Deposit amount 3. Withdraw amount We assume that there is an opening balance of 1000 available in the system (Assign balance=1000.0 in the beginning of the code). Also, while running first start by choosing deposit option or withdraw option.

In: Computer Science

Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this...

Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this course (CSC100 online) based on three user inputs. This program should begin by printing the title of the application (program) and a brief description of what it does. (Note: this is NOT the same as the program prolog: a prolog is much more detailed, has required elements, and is intended for other programmers reading the cpp file. The title and description displayed by the program are meant for the user of the program.)

Next, the program must prompt the user for three integer inputs in the following order: 1) Points earned on programming assignments, 2) Points earned on MPL homework, and 3) Points earned on the final exam. Each prompt should be clear, concise, and free of spelling errors. After getting all three of the integer inputs, the program should either print an input validation error message and then terminate or output the required data for this program.

If an input error is detected, one and only one of the following error messages should be displayed:

  1. The number of points entered for Programming Assignments must be between 0 and 400, inclusive.
  2. The number of points entered for MPL Homework must be between 0 and 200, inclusive.
  3. The number of points entered for the Final Exam must be between 0 and 400, inclusive.

After displaying one of these error messages, the program should terminate after displaying:
myGrade is now terminating.

Only if there is no input error would the program continue normal execution. This means that the next step after all three inputs are validated is to make the necessary calculations and determinations to display the following items of information to the user in this order:

  1. The number of Programming Assignment points entered
  2. The number of MPL Homework points entered
  3. The number of Final Exam points entered
  4. The total number of points earned
  5. The student's letter grade
  6. A support message based on the letter grade earned

Each numeric value displayed should be preceded by a clear, concise label stating what the number means. The total points earned is the sum of the three integers input by the user. The letter grade is determined by matching the total points to the correct row in the table given under the Grading section in the Syllabus. Your code will need to implement efficient grade range checks to determine the appropriate letter grade based on the table in the syllabus. Use named constants for the grade range boundaries (900, 800, etc.) and store the determined letter grade as an upper case letter in variable of type, char. Do not use any variables of type, double, in this program: double is not needed since all entries are integers and the grade range boundaries are integers. Your program must also implement the course rule that automatically assigns a letter grade of F when the Final Exam points earned are less then 240, i.e., 60% of the total possible.

Your program must use a switch statement on the letter grade (type, char) to print one and only one of the following support messages:

  1. For an A, print:      Great job! You will have no problem in CSC205.
  2. For a B, print:        Good job! You should have little trouble in CSC205.
  3. For a C, print:        Ok, you passed, but you may be challenged in CSC205.
  4. For a D, print:       When you retake this course, you will be able to do much better.
  5. For an F, print either:
              You did not put forth enough effort to pass this course.
    or
              You did not score enough points on the Final Exam to pass this course.

Once all six items of information are displayed (in the order listed above), the program should terminate after displaying:

myGrade is now terminating.


TRUE for THIS and ALL programs submitted in this course:
Avoid unnecessary point deductions by formatting your code AND following ALL pertinent coding conventions. Make sure all requirements are implemented. Make sure the program does not calculate or display anything that is NOT required. Remember named constants.

Example of Output:

Example output from your program if the three inputs were: 305 (programming assignments), 108 (MPL Homework), and 288 (Final Exam):

Programming Assignment points entered: 305
MPL Homework points entered           108
Final Exam points entered:            288
Total number of points earned:          701           
Student's letter grade earned:        C
     Ok, you passed, but you may be challenged in CSC205.

Example output from your program if the three inputs were: 400 (programming assignments), 200 (MPL Homework), and 239 (Final Exam):

Programming Assignment points entered: 400
MPL Homework points entered         200
Final Exam points entered:            239
Total number of points earned:      839           
Student's letter grade earned:            F
     You did not score enough points on the Final Exam to pass this course.

Example output from your program if the three inputs were: 275 (programming assignments), 80 (MPL Homework), and 240 (Final Exam):

Programming Assignment points entered: 275
MPL Homework points entered            80
Final Exam points entered:            240
Total number of points earned:      595           
Student's letter grade earned:            F
     You did not put forth enough effort to pass this course.

Example output from your program if the three inputs were: -348 (programming assignments), 139 (MPL Homework), and 300 (Final Exam):

Programming Assignment points entered: -348
MPL Homework points entered           139
Final Exam points entered:              300
The number of points entered for the Programming Assignments must be between 0 and 400, inclusive.

All I have so far is this and I am stuck on what to do:

#include <iostream>

using namespace std;

int main()
{

const int possible = 1000;
const int ASSIGNMENT = 400;
const int HW = 200;
const int FINAL = 400;
const int A = 90;
const int B = 80;
const int C = 70;
const int D = 60;
const int F = 59;

int assignment;
int MPLHomework;
int FinalExam;
int grade;
int total;

//Stating the name of the program and what it does
cout << "Welcome to the Grade Calculator" << endl;
cout << "The following program will calculate your grade\n";
cout << "in CSC205 by averaging three inputs such as\n";
cout << "your points from programming assignments, MPL homework, and the final exam." << endl;

//Receiving user input
cout << "Please enter the amount of points for your Programming Assignments:" << assignment << endl;
cin >> assignment;

cout << "Please enter the amount of points for your MPL Homework:" << MPLHomework << endl;
cin >> MPLHomework;

cout << "Please enter the amount of points for your Final Exam:" << FinalExam << endl;
cin >> FinalExam;

total = FinalExam + assignment + MPLHomework;

if (assignment <= ASSIGNMENT && MPLHomework <= HW && FinalExam <= FINAL)
  
cout << "Programming Assignment points entered:" << assignment << endl;
cout << "MPL Homework points entered:" << MPLHomework << endl;
cout << "Final Exam points entered:" << FinalExam << endl;
cout << "Total number of points earned:" << total << endl;

//Determining if the user input has an error and termination

return 0;
}

In: Computer Science

C++ function to a string into enum function to a enum into a string check valid...

C++

function to a string into enum

function to a enum into a string

check valid / loop ( asking a couple of times until answer invaild)

For example

Enum Fruit ( APPLE, STRAWBERRY, BLUEBERRY, BLACKBERRY)

output should be

what is your favorit fruit? : strawberry

you will have STRAWBERRY.

what is your favorite fruite : peach

invaild

TIA

In: Computer Science

Assignment Description Write a program that will have a user guess whether a person is a...

Assignment Description

Write a program that will have a user guess whether a person is a musician or a writer. You will create a

group of four names, two musicians and two writers, and show the user a name randomly selected from

the four. The user will then guess whether they think the name belongs to a musician or writer. After a

guess, the program will tell the user whether they are correct, repeat the name, and reveal the correct

answer.

Tasks

1) The program needs to contain the following

a.

A comment header containing your name and a brief description of the program

b. At least 5 comments besides the comment header explaining what your code does

c.

Four string variables, two musicians and two writers

d. A way to randomly display one of the four names to the user

e. Output asking the user whether the name displayed is a musician or a writer

i. If the user guesses correctly, congratulate them before outputting the displayed

name and the correct answer

ii. If the user guesses incorrectly, output the displayed name and the correct

answer

f.

“Press enter to continue” and Console.Read(); at the end of your code

2) Upload the completed .cs file onto the Assignment 3 submission folder. To access the .cs file:

a.

Right click on your program tab

b. Click “Open containing folder”

c.

The file you are working on will be there with a .cs extention, upload the .cs file


please code in C#- (C Sharp)

In: Computer Science

In this assignment, you will implement Breadth First Search (BFS). The input to your program is...

In this assignment, you will implement Breadth First Search (BFS). The input to your program is a graph in the adjacency list format. The input graph has at most 100 vertices. Your program must initiate a BFS from vertex 2 of the graph. If the graph is connected, your program must output “Graph is connected”. If the graph is disconnected, your program must output “Graph is not connected”. Your program should read from an input file: data2.txt and write to the output file: out2.txt.

Your program should be written in C or C++. You can use STL for a queue but not for a graph.

Input Example

1 3 4

2 4

3 1 4

4 2 1 3

1 2 4

2 1 3

3 2 4

4 1 3

1 2

2 1

3 4

4 3

In: Computer Science

need to write code for a Paint job estimator program on python specs: A painting company...

need to write code for a Paint job estimator program on python

specs:

A painting company has determined that for every 350 square feet of wall space, one gallon of paint and six hours of labor are required. The company charges $62.25 per hour for labor. Write a program call paintjobestimator.py that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon. The program is to display the following information.

  • The number of gallons of paint required rounded up to whole gallons.
  • The hours of labor required.
  • The cost of the paint based on the rounded up whole gallons.
  • The labor charges.
  • The total cost of the paint job.

At the end of one estimate the user it to be asked if they would like to perform another estimate. Use the prompt: Would you like to do another estimate? (y/n) If the user answers y, then the program is to accept input for another estimate. If the user answers with anything other than y, the program is to exit.

The user input should not be able to crash the program. If the user provides invalid input the program should tell the user why the input is invalid and ask again for the input.  

The square feet of wall space and the price of the paint per gallon must be positive values. If the user enters 0 or a negative value, the program should tell the user why the input is invalid and ask again for the input.

The output is to be nicely formatted. Hours of labor is to be displayed to one decimal point (example: 12.4 hours). Gallons of paint is to be displayed as an integer value with nothing shown to the right of the decimal point (example: 5). Total labor charges is to be displayed to two decimal points and a $ is to be displayed at the start of the total labor charge value (example: $152.64).

The gallons of paint is rounded up to whole gallons because the paint is colored and mixed in whole gallons. If paint is left over it can’t be used on another job. You will need to find a way in Python to do the math to calculate the gallons of paint so that the result is a whole number that is a rounded up value based on the division of the square feet of space by the 350 square feet per gallon. For example, if the area to be painted is 1800 square feet, then 1800 / 350 is 5.142857 gallons. The rounded up whole gallons result is 6. Five gallons of paint is not enough. The need for some amount more than 5 gallons means the job requires 6 gallons even if all of it will not be used.

this is what i have so far:

import math


def main():
while True:

# Taking the input from the user for the square feet of the wall to paint and ask use until the user enters positive integer value

while True:

square_feet = input('Enter square feet of wall to paint: ')

square_feet = int(square_feet)

if square_feet < 0:

print('square feet has to be positive integer')

continue

elif square_feet == 0:

print('square feet must be positive not zero')

continue

# if square feet is greater than 0 the loop terminates

else:

break

# Taking the input from the user for the pricePaint of the painting bucket and ask the user until the user enters positive integer value

while True:

pricePaint = input('Enter pricePaint of paint per gallon: ')

pricePaint = int(pricePaint)

if pricePaint < 0:

print('price has to be positive integer')

continue

elif pricePaint == 0:

print('price has to be positive integer not zero')

continue

# if pricePaint > 0 the loop terminates

else:

break

# getting Gallons based on the price of the paint

Gallons = square_feet / 350

# calculating the number of numOfHours required to paint

number_of_hours = Gallons * 6

Gallons = math.ceil(Gallons)

# getting cost of the paint from Gallons

paintCost = pricePaint * Gallons

# getting theLaborCharge based on number of numOfHours

the_Labor_Charge = 62.25 * number_of_hours

# calculating total paint cost

totalCost = paintCost + the_Labor_Charge

print("Gallons: %5d, number of hours of labor: %.1f, Paint Cost: %.2f, the Labor Charge: $%.2f, Total Paint Cost: $%.2f" % (
Gallons, number_of_hours, paintCost, the_Labor_Charge, totalCost))

# getting choice from user

choice = input('Would you like to do another estimate(y/n)? ')

# if the choice is yes the program will do another estimate

if choice.upper() == 'Y':

pass

# if the choice is no or anything then program will terminate

elif choice.upper() == 'N' or choice.upper() != 'N':

break


if __name__ == "__main__":
main()

----

when the user puts in a negative number or 0 for the square ft of wall space and price of paint it advises them to use another value but when they use a decimal number such as "9.99" it crashes.

I need to make to where it takes all kinds of inputs including decimal numbers and advise them to try another value if they put in 0 or a negative number. if someone could also help me tidy up how it spits the end result it would be great

In: Computer Science

ASSEMBLY LANGUAGE PROGRAMMING Q:Write a complete assembly program that inputs a small signed integer n, whose...

ASSEMBLY LANGUAGE PROGRAMMING

Q:Write a complete assembly program that inputs a small signed integer n, whose value can fit within 8 bits, and outputs the value of the expression n2n + 6.

In: Computer Science

Write the c++ program of Secant Method and Fixed point Method in a one program using...

Write the c++ program of Secant Method and Fixed point Method in a one program using switch condition .Like :

cout<<"1.Secant Method \n 2. Fixed point Method\n"<<endl; if press 1 then work Secant Method if press 2 then work Fixed point Method .so please writhe the code in c++ using switch case.and the equation given down consider the equation in the given.Note: Must showt the all the step of output all the iteration step shown in the program .in program must shown all the step of iteration result

for secant method equation :4x3-2x-6=0

for fixed point=x2-x-1=0

Please in every itaration must be shown the output then finally Got the root

In: Computer Science

Write a program that checks whether or not a date entered in by the user is...

Write a program that checks whether or not a date entered in by the user is valid. Display the date and say if it is valid. If it is not valid explain why.

  • The input may be in the format mm/dd/yyyy, m/d/yyyy, mm/d/yyyy, or m/dd/yyyy.
  • A valid month (mm) must be from 1 to 12
  • A valid day (dd) must be from 1 to the appropriate number of days in the month
    • April, June, September, and November have 30 days
    • February has 28 except for leap years, then it has 29
    • The rest have 31 days
    • Leap years are years that are divisible by 4 BUT not divisible by 100 unless it is also divisible by 400

I don't need the coding. Just help with the questions 1 and 2.

  1. Include a flow chart in your proposed solution section
  2. Write the equivalent Boolean expression !(a>b)&&!(b==c) which doesn’t use the NOT operator (!). Assume that a, b, and c are integers.

In: Computer Science

Using the idea of the Bubble Sort algorithm, design an algorithm in pseudocode that gets 3...

Using the idea of the Bubble Sort algorithm, design an algorithm in pseudocode that gets 3 numbers a, b, c, from the user, and prints the 3 numbers in ascending order

In: Computer Science

In each of the projects that follow, you should write a program that contains an introductory...

In each of the projects that follow, you should write a program that contains an introductory docstring. This documentation should describe what the program will do (analysis) and how it will do it (design the program in the form of a pseudocode algorithm). Include suitable prompts for all inputs, and label all outputs appropri- ately. After you have coded a program, be sure to test it with a reasonable set of legitimate inputs.

5 An object’s momentum is its mass multiplied by its velocity. Write a pro- gram that accepts an object’s mass (in kilograms) and velocity (in meters per second) as inputs and then outputs its momentum.

6 The kinetic energy of a moving object is given by the formula KE=(1/2)mv2, where m is the object’s mass and v is its velocity. Modify the program you created in Project 5 so that it prints the object’s kinetic energy as well as its momentum.

Write a program that takes as input a number of kilometers and prints the corresponding number of nautical miles. Use the following approximations:

- A kilometer represents 1/10,000 of the distance between the North Pole and the equator.

- There are 90 degrees, containing 60 minutes of arc each, between the North Pole and the equator.

- A nautical mile is 1 minute of an arc.

*please use IDLE( python 3.7)

In: Computer Science

Please convert decimal value -32760 into 2's complement binary value

Please convert decimal value -32760 into 2's complement binary value

In: Computer Science