Draw the binary tree representation of the following arithmetic expression:
"( ( ( 6 + 3 ) * ( 3 - 2 ) ) / ( ( 3 + 10 ) + ( ( 8 - 3 ) - 2 ) ) * 9 )"
-Give an O(n)-time algorithm for computing the depth of all positions of a tree T, where n is the number of nodes of T.
In: Computer Science
Chapter 6: Use a list to store the players
Update the program in python so that it allows you to store the players for the starting lineup. This
should include the player’s name, position, at bats, and hits. In addition, the program
should calculate the player’s batting average from at bats and hits.
Console
================================================================
Baseball Team Manager
MENU OPTIONS
1 – Display lineup
2 – Add player
3 – Remove player
4 – Move player
5 – Edit player position
6 – Edit player stats
7 - Exit program
POSITIONS
C, 1B, 2B, 3B, SS, LF, CF, RF, P
================================================================
Menu option: 2
Name: Mike
Position: C
At bats: 0
Hits: 0
Mike was added.
Menu option: 1
Player POS AB H AVG
----------------------------------------------------------------
1 Joe P 10 2 0.2
2 Tom SS 11 4 0.364
3 Ben 3B 0 0 0.0
4 Mike C 0 0 0.0
Menu option: 6
Lineup number: 4
You selected Mike AB=0 H=0
At bats: 4
Hits: 1
Mike was updated.
Menu option: 4
Current lineup number: 4
Mike was selected.
New lineup number: 1
Mike was moved.
Menu option: 7
Bye!
Specifications
Use a list of lists to store each player in the lineup.
Use a tuple to store all valid positions (C, 1B, 2B, etc).
Make sure that the user’s position entries are valid.
In: Computer Science
What is launch angle and Launch velocity(ms) to hit target 153 feet away
In: Computer Science
Write code that will produce the following pyramid for a user designated number of rows (user input).
1
11
121
12321
1235321
(Based on Fibonacci numbers)
*USE JAVA*
In: Computer Science
why study computer architecture and organization
In: Computer Science
convert -44 to 8-bit sign-magnitude, 1's complement, 2's complement and excess-127.
Please be careful and explain all the steps and details.
In: Computer Science
JAVA CODE
Write two definitions of a boolean method called equals(). The method compares the instance variables of the class for equality. One is in the Purchase class and the other is a static method of the main. Give sample calls for each.
public class PurchaseDemo
{ public static void main(String[] args)
{
Purchase oneSale = new Purchase();
oneSale.readInput();
oneSale.writeOutput();
System.out.println("Cost each $" + oneSale.getUnitCost());
System.out.println("Total cost $" + oneSale.getTotalCost());
}
}
import java.util.Scanner;
/**
Class for the purchase of one kind of item, such as 3
oranges.
Prices are set supermarket style, such as 5 for $1.25.
*/
public class Purchase
{
private String name;
private int groupCount; //Part of a price, like the 2 in //2 for
$1.99.
private double groupPrice; //Part of a price, like the $1.99
// in 2 for $1.99.
private int numberBought; //Number of items bought.
public void setName(String newName)
{
name = newName;
}
/**
Sets price to count pieces for $costForCount.
For example, 2 for $1.99.
*/
public void setPrice(int count, double costForCount)
{
if ((count <= 0) || (costForCount <= 0))
{
System.out.println("Error: Bad parameter in " +
"setPrice.");
System.exit(0);
}
else
{
groupCount = count;
groupPrice = costForCount;
}
}
public void setNumberBought(int number)
{
if (number <= 0)
{
System.out.println("Error: Bad parameter in " +
"setNumberBought.");
System.exit(0);
}
else
numberBought = number;
}
/**
Reads from keyboard the price and number of a purchase.
*/
public void readInput()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter name of item you are purchasing:");
name = keyboard.nextLine();
System.out.println("Enter price of item as two numbers.");
System.out.println("For example, 3 for $2.99 is entered as");
System.out.println("3 2.99");
System.out.println("Enter price of item as two numbers, " +
"now:");
groupCount = keyboard.nextInt();
groupPrice = keyboard.nextDouble();
while ((groupCount <= 0) || (groupPrice <= 0))
{ //Try again:
System.out.println("Both numbers must " +
"be positive. Try again.");
System.out.println("Enter price of " +
"item as two numbers.");
System.out.println("For example, 3 for " +
"$2.99 is entered as");
System.out.println("3 2.99");
System.out.println(
"Enter price of item as two numbers, now:");
groupCount = keyboard.nextInt();
groupPrice = keyboard.nextDouble();
}
System.out.println("Enter number of items purchased:");
numberBought = keyboard.nextInt();
while (numberBought <= 0)
{ //Try again:
System.out.println("Number must be positive. " +
"Try again.");
System.out.println("Enter number of items purchased:");
numberBought = keyboard.nextInt();
}
}
/**
Displays price and number being purchased.
*/
public void writeOutput()
{
System.out.println(numberBought + " " + name);
System.out.println("at " + groupCount +
" for $" + groupPrice);
}
public String getName()
{
return name;
}
public double getTotalCost()
{
return (groupPrice / groupCount) * numberBought;
}
public double getUnitCost()
{
return groupPrice / groupCount;
}
public int getNumberBought()
{
return numberBought;
}
}
In: Computer Science
Question 1 (Employee): Base Class Information 10 Points
Employee Name: FirstName LastName
Mobile No. 0512345678
Employee Salary: 2000
In: Computer Science
convert -44 to 8-bit sign-magnitude, 1's complement, 2's complement and excess-127.
Please be careful and explain all the steps and details.
In: Computer Science
Python Code
Assignment
1. Place the two provided plaintext files (file_1.txt, file_2.txt) on your desktop.
2. Write a Python program named fun_with_files.py. Save this file to your desktop as well.
3. Have your program write the Current Working Directory to the screen.
4. Have your program open file_1.txt and file_2.txt, read their contents and write their contents into a third file that you will name final.txt .
Note: Ponder the open‐read/write‐close file operation sequence carefully.
5. Ensure your final.txt contains the complete text of file_1.txt followed by the complete text of file_2.txt.
In: Computer Science
Write a program named "cleanDocument.pl" that will do the following:
Below is an example of how the program works:
Calling the Perl file on the command line like so:
$ cleanDocument.pl document.txt bobsled
or
$ cleanDocument.pl $ What file do you want to open? document.txt $ What word do you want to replace? bobsled
If the file looks like below:
$ cat document.txt I like to use my bobsled during the winter. Whenever I bobsled I have a lot of fun.
Then it will be become:
$ cat document.txt I like to use my ------- during the winter. Whenever I ------- I have a lot of fun.
In: Computer Science
You prepare a schedule of your physical exercises for the next fortnight (14 days). You don’t do physical exercise more than once a day. If you have 10 PE sessions planned, explain using the counting principles covered in class how this means you will do PE on consecutive days at least once in the next fortnight.
In: Computer Science
how do you create a list in python to calculate BMI, if you were to want variables like height, weight, BMI, and classification in the list
In: Computer Science
Write a VB program to provide a health analysis. The higher the point total, the less healthy you are. Input will consist of the user's name, age group, smoker status, weight, sex, blood pressure, and cholesterol readings.
Risk Points are assigned as follows:
Age Group
18 or below0 points
19 - 301 point
31 - 602 points
over 604 points
Smoker?
Yes 5 points
No 0 points
Systolic Blood Pressure?
60 - 139 (Normal) 0 points
140 - 159 (Borderline) 2 points
over 159 (High) 4 points
Diastolic Blood Pressure?
40 - 89 (Normal) 0 points
90 - 94 (Borderline) 2 points
over 94 (High) 4 points
LDL (Bad) Cholesterol
< 110 0 points
110 and up 2 points
HDL (Good) Cholesterol
> 1/5 of Total Cholesterol 0 points
≤ 1/5 of Total Cholesterol 2 points
Weight
Female, over 200 lbs 3 points
Female, 150 - 200 lbs 2 points
Female, < 150 lbs 0 points
Male, over 260 lbs 3 points
Male, 200 - 260 lbs 2 points
Male, < 200 lbs 0 points
A sample user-interface design is attached for your use. Note that the user's name, and cholesterol readings are to be entered into textboxes. The sex and smoking status are entered via radio buttons. The weight and blood pressure (systolic and diastolic) are entered via Numeric UpDown controls. The age group is chosen from a combo box control.
The primary button on your form (Analyze Data) will contain all the code to solve this problem in its Click event procedure. You should also make this event procedure executable by simply pressing the ENTER key when the program runs.
Two other buttons...Quit (to pop up a "Farewell Greeting" message box to the user and stop program execution), and a Clear button (to reset all controls back to original values, and move the cursor back to the "Name" textbox), should also have their click event procedures coded.
Finally, a listbox should be included on your form to output the user's results as follows.
Note:
Total Cholesterol is LDL Cholesterol plus HDL Cholesterol.
Health Status is determined as follows:
Total Points Status
0 - 9Good
10 - 18Average
19 - 24Poor
Programming Notes
1. All code to solve this problem will be written in the "Analyze Data" Click event procedure. Therefore, all variables (meaningful, and properly data-typed) will be declared locally to this event procedure. No global (form-level) variables should be used.
2. The following variables and corresponding data types are suggested (You can add prefixes as needed).
Variable Data Type
namestring
weightinteger
HDLinteger
LDLinteger
TotalCholesterolinteger
SystolicBPinteger
DiastolicBPinteger
SmokePointsinteger
WtPointsinteger
AgePointsinteger
LDL Pointsinteger
HDL Pointsinteger
SystolicPointsinteger
DiastolicPointsinteger
TotalPointsinteger
HealthStatusstring
3. Code OPTION STRICT ON at class level to ensure all variables are properly declared in your program.
4. Use IF statements (single, dual, or multiple alternative, as needed) to determine points from Smoking, Systolic blood pressure, Diastolic blood pressure, HDL Cholesterol, LDL Cholesterol, and weight.
For example, suppose you want to assign points for user's smoking status. You would code the following:
Dim SmokePoints As Integer
If radSmokeYes.Checked = True Then
SmokePoints = 5
Else
SmokePoints = 0
End If
5. Use a Select/Case statement to determine points from the age group of the user.
6. Although you set the min/max for 40/300 for Systolic nud (in the Initial Properties Window), use data validation to ensure that user enters an integer between 60 and 200 inclusive into the Systolic Blood Pressure numeric updown control. If not, display an appropriate error message (via titled, descriptive message box), set insertion point back to Systolic Blood Pressure numeric updown control to allow the user to try again and Exit Sub to prevent further execution without having all the "input data.".
7. Do the same as in Step 6 above but set the min/max for 20/200 for Diastolic nud, for the Diastolic Blood Pressure reading, ensuring the user enters an integer between 40 and 120 inclusive.
I just need help with the coding of the project. Any help would be appreciated :)
In: Computer Science