In: Computer Science
In: Computer Science
Create and test a Windows Console application that displays the following patterns separately, one after the other. You MUST use nested for loops to generate the patterns, like the example in the PowerPoint slides from this chapter. All asterisks (*) should be displayed by a single statement of the form Console.Write("*"); which causes the asterisks to display side by side. A statement of the form Console.WriteLine(); can be used to move to the next line. A statement of the form Console.Write(" "); can be used to display a space for the last two patterns. There should be no other output statements in the application, other than labeling each pattern. The application's output should look like the following: Remember, use Debug, Start Without Debugging (CTRL-F5) to run your Console application. For Pattern C and Pattern D, you will need TWO loops (one after the other) nested inside your outer loop. The first loop will produce a certain number of spaces. The second loop will produce a certain number of stars. One of these numbers will be the current value of your outer loop's control variable. The other number must be calculated using ALGEBRA. Consider, how many spaces and stars are being output on each row? Always the same amount (here, 10 or MAX_ROWS, if using the same named constant as in the PowerPoint slide code given for Pattern A). So, (# spaces) + (# stars) = MAX_ROWS This equation is easy to solve for the number of spaces needed (assuming your outer loop control variable represents that number of stars per row, as in the PowerPoint slide code given for Pattern A): (# spaces) = MAX_ROWS - (# stars) or (# spaces) = MAX_ROWS - row if you name your variables as in the PowerPoint slide code given for Pattern A. So, you can make your first nested loop start at 1 and count up to (MAX_ROWS - row), outputting a single space on each iteration
Pattern A * ** *** **** ***** ****** ******* ******** ********* ********** Pattern B ********** ********* ******** ******* ****** ***** **** *** ** *
(c)
**********
*********
********
*******
******
*****
****
***
**
*
(d)
*
**
***
****
*****
******
*******
********
*********
In: Computer Science
Finish the calories_burned_functions.py program that we started in class. Take the original calories_burned program and rework it so that it uses two functions/function calls.
Use the following file to get your program started:
"""
''' Women: Calories = ((Age x 0.074) - (Weight x 0.05741) +
(Heart Rate x 0.4472) - 20.4022) x Time / 4.184 '''
''' Men: Calories = ((Age x 0.2017) + (Weight x 0.09036) + (Heart
Rate x 0.6309) - 55.0969) x Time / 4.184 '''
"""
#Declare Variable names and types
age_years = int(input())
weight_pounds = int(input())
heart_bpm = int(input())
time_minutes = int(input())
#Performing Calculations
calories_woman = ( (age_years * 0.074) - (weight_pounds * 0.05741)
+ (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184
calories_man = ( (age_years * 0.2017) + (weight_pounds * 0.09036) + (heart_bpm * 0.6309) - 55.0969 ) * time_minutes / 4.184
#Print and format results in detail
print('Women: {:.2f} calories'.format(calories_woman))
print('Men: {:.2f} calories'.format(calories_man))
"""
#Here are the functions to this program
def calc_calories_woman(years, pounds, heartrate,
minutes):
return ( (age_years * 0.074) - (weight_pounds * 0.05741) +
(heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184
#This is the main part of the program
#------------------------------------------------------------------------------
#Prompt the user at the keyboard for the necessary information
age_years = int(input("Please enter your age: "))
weight_pounds = int(input("Please enter your weight: "))
heart_bpm = int(input("Please enter your heart rate: "))
time_minutes = int(input("Please enter the time: "))
#Calculate the calories
calories_woman = ( (age_years * 0.074) - (weight_pounds * 0.05741) + (heart_bpm * 0.4472) - 20.4022 ) * time_minutes / 4.184
calories_man = ( (age_years * 0.2017) + (weight_pounds * 0.09036) + (heart_bpm * 0.6309) - 55.0969 ) * time_minutes / 4.184
#Print the results
print('Women: {:.2f} calories'.format(calories_woman))
print('Men: {:.2f} calories'.format(calories_man))
In: Computer Science
Provide a comparison of at least 10 Internet of Things communication protocols. Provide your answer in a table format labelling each comparison parameter with a suitable heading. Use at least 5 parameters for comparison.
In: Computer Science
There are various methods which organizations can use to acquire a new system. Some of these include: outsourcing, off-the-shelf software and in-house development. Select two of these three methods to acquire software and discuss the advantages and disadvantages of each. Which do you believe is the preferred method of systems acquisition
In: Computer Science
Calculate the Area and Perimeter for shapes using functions in Python.
Your goal is to match the sample output below:
Welcome to my area and perimeter calculator ====================================================== Circle : area = 39.82, perimeter = 22.37 Square : area = 85.19, perimeter = 36.92 Rectangle: area = 41.24, perimeter = 34.24 Triangle : area = 21.16
Here is the code to use for your program (Note you may have to type this code into Trinket directly)
import math
# Add your code here
# TODO -> Add welcome function here
# TODO -> Add circle area function here
# TODO -> Add circle perimeter function here
# TODO -> Add square area function here
# TODO -> Add Square perimeter function here
# TODO -> Add rectangle area function here
# TODO -> Add rectangle perimeter function here
# TODO -> Add triangle area function here
# =====================================================================
# Main Code - DO NOT EDIT ANYTHING BELOW. Add your functions above
displayWelcome()
radius = 3.56
area = calcAreaCircle(radius)
perimeter = calcPerimeterCircle(radius)
print('Circle : area = {0:.2f}, perimeter = {1:.2f}'.format(area, perimeter))
side = 9.23
area = calcAreaSquare(side)
perimeter = calcPerimeterSquare(side)
print('Square : area = {0:.2f}, perimeter = {1:.2f}'.format(area, perimeter))
width = 2.9
height = 14.22
area = calcAreaRect(width, height)
perimeter = calcPerimeterRect(width, height)
print('Rectangle: area = {0:.2f}, perimeter = {1:.2f}'.format(area, perimeter))
base = 7.97
height = 5.31
area = calcAreaTriangle(base, height)
print('Triangle : area = {0:.2f}'.format(area))In: Computer Science
Open two windows in Ubuntu, and list the content of the /dev/fd folder. Can you explain the difference observed from the two windows? The name /dev/fd is actually a symbolic link to /proc/self/fd. The name self is also a symbolic link pointing to a number, which is the process ID of the current process. Therefore, the number pointed to by self is different if viewing from different windows.
In: Computer Science
URGENT PLZ - BASIC PYTHON
Use the following format for each of your files in the header.
# Name:
# Date:
# Description:
You programs should be FULLY COMMENTED.
Mr. Zapanta has locked himself out of his laptop and completely forgotten his password (the password is “cardinalcarter123” or “CardinalCarter123”). Write a program that generates a password entry. The program will display an appropriate message if Mr. Zapanta enters the wrong password. The program will allow a maximum of 5 tries to enter. If he exceeds 5 tries, the program will stop and display “Your laptop has been locked”. (5 marks Thinking) (Use a while loop)
Sample Output 1:
Enter the password: mr. zapanta
That is not the correct password! Try again.
Enter the password: cardinal carter
That is not the correct password! Try again.
Enter the password: ilovecompsci
That is not the correct password! Try again.
Enter the password: carter123
That is not the correct password! Try again.
Enter the password: chicken321!
That is not the correct password! You’ve reached the max number of tries.
Your laptop has been locked.
Sample Output 2:
Enter the password: mr. zapanta
That is not the correct password! Try again.
Enter the password: cardinalcarter123
Welcome, Mr. Zapanta.
In: Computer Science
B) DML and SQL Query
For this DB Schema, answer the below questions:
Employee (Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary,
Super_ssn, Dno)
Department (Dname, Dnumber, Mgr_ssn, Mgr_start_date)
5. Delete from Employee table, those who have First name:
James.
6. Delete from Employee table, those who have Salary more than
4000.
7. What happens if you try to delete one department?
8. Retrieve the data of all employee.
9. Retrieve the data of all male employee.
10. Retrieve the Fname, Lname of all male employee.
11. Retrieve the Fname, Lname and Salary of all employee
12. Retrieve the Fname, Lname and Salary of all employee with
Salary more than 4000
13. Retrieve the Fname, Lname and Salary of all female employee
with Salary more than 4000
14. Retrieve the Fname, Lname and Address of all female employee
with Salary more than 4000 and Birthdate after 1-1-1990.
15. Retrieve the Address and Salary of all employee with Fname =
John or James.
16. Retrieve the Address and Salary of all employee with Fname =
John or Birthdate after 1-1-1990
17. Retrieve the Name and Number of all Departments
18. Retrieve the Name and Number of all Departments with Manager
SSN=123456
19. Retrieve the Employee Fname, Lnameand Department number for all
employees.
20. Retrieve the Employee Fname, Lnameand Department number and
Department Name for all employees.
21. Retrieve the Employee Fname, Lnameand who works in Department
name = Research
22. Retrieve the Employee Fname, Lnameand who works in Department
name = Research and IT
23. Retrieve the Employee Fname, Lnameand who works in Department
name = Research OR IT
24. Retrieve the Department Name ,Number , Manager SSN
25. Retrieve the Department Name ,Number , Manager SSN, Manager
FName
26. Retrieve the Department Name, Manager SSN, Manager FName for
departments with Manager Start Date > 1-1-2010
please write it in computer word not pin and thank you
In: Computer Science
need algorithm not code otherwise will downvote 10
times use ms team or latex code or pdf only
Consider an n-node complete binary tree T, where n = 2d − 1 for
some d. Each node v of T is labeled with a real number xv. You may
assume that the real numbers labeling the nodes are all distinct. A
node v of T is a local minimum if the label xv is less than the
label xw for all nodes w that are joined to v by an edge.
You are given such a complete binary tree T, but the labeling is
only specified in the following implicit way: for each node v, you
can determine the value of xv by probing the node v. Show how to
find a local minimum of T using only O(logn) probes to the nodes of
T.
Note:- dont use handwritten image
In: Computer Science
This question concerns writing a Student class to model a
student's name, composed
of a first name, middle name and last name. The Student class
should meet the
following specification:
| Class Student A Student object represents a student. A student has a first name, middle name and last name. Methods public void setNames(String first, String middle, String last) // Set the first, middle and last names of this Student object. public String getFullName() // Obtain the full name of this Student with the middle name converted to an initial only. |
2
Thinking of the problem in terms of testing, there are three
requirements that must be
met:
1. The setNames() method sets the names stored in the object i.e.
the values of
firstName, middleName, lastName.
2. The getFullName() method obtains the name of the student with
the middle name
converted to an initial only.
3. The getFullName() method does not change anything – i.e. it does
not modify the
values of firstName, middleName, lastName
HINT: To start your Student class, we suggest using the following
instance variables:
Instance variables
private String firstName;
private String middleName;
private String lastName;
In order to test the requirement above create a java class called
StudentTest that allows
the user to enter the first name, middle name and last name. These
values must be set
using the created set meothod and afterwards displays the
information back to the
console, however the Middle name is an initial ONLY
In: Computer Science
Complete Answer Must Compile in Visual Code in template Form Code, Must Reflect in UI.
1. Add a new text box - Mavenlink Project Name
2. Once we enter project name and project code , on tab change Mavenlink Project Name should be set as
Project Code - Project Name
Example :
Project Code = T1002
Project Name = TEST123
So in this case Mavenlink Project Name will be T1002 - TEST123
In: Computer Science
Write a program that does the following in order:
1. Asks the user to enter a name
2. Asks the user to enter a number “gross income”
3. Asks the user to enter a number “state tax rate”
4. Calculates the “Federal Tax”, “FICA tax” and “State tax”
5. Calculates the “estimated tax” and round the value to 2 decimal places
6. Prints values for “name”, “gross income” and “estimated tax”
The program should contain three additional variables to store the Federal tax, FICA tax, State tax, gross income, and estimated tax.
Federal Tax = gross income * 9.45%
FICA Tax = gross income * 7.65%
State Tax = gross income * your state tax percent
Estimated Tax = Federal tax + FICA tax + State tax
NOTE: Percentages must be converted to decimal values, for example:
15.9%=15.9*0.01=0.159
An example of the program’s input and output is shown below:
Enter your name: Belinda Patton
Enter your gross income: 53398.12
Enter your state income tax rate: 4.27
Tony Johnbull estimated tax is $11411.08 based on a gross income of $53398.12
In: Computer Science
1-Using the Note class and make it Comparable. A Note is larger than another note if it is higher in frequency. 2-In the driver program create a few objects and compare them . then create a list of those objects and sort them. 3. Rewrite the Note class so that a list of Notes is sorted first by length of note, then within that by frequency.
import java.io.*;
import java.math.*;
public class NoteTester
{
public static void main(String[] args) throws IOException
{
//Declare variables to hold user input
double noteValue;
String noteLength;
int tempLength;
//Create BufferedReader object wrapped with InputStreamReader to hold user input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//Retrieve starting value from user
System.out.println("Please enter a value for your note\n"+
"between -48 and 39:");
noteValue = Double.parseDouble(br.readLine());
//While loop ensures a valid number
while(noteValue < -48 || noteValue > 39)
{
System.out.println("Please enter a valid value for your note\n"+
"between -48 and 39:");
noteValue = Double.parseDouble(br.readLine());
}
//Retrieve starting length from user
System.out.println("Please enter the number between 1-5\n" +
"you would like to represent\n" +
"the length of your note.\n"+
"1. Whole\n" +
"2. Half\n" +
"3. Quarter\n" +
"4. Eighth\n" +
"5. Sixteenth");
tempLength = Integer.parseInt(br.readLine());
//While loop ensures a valid length
while(tempLength > 5 || tempLength < 1)
{
System.out.println("Please enter the number between 1-5\n" +
"you would like to represent\n" +
"the length of your note.\n"+
"1. Whole\n" +
"2. Half\n" +
"3. Quarter\n" +
"4. Eighth\n" +
"5. Sixteenth");
tempLength = Integer.parseInt(br.readLine());
}
//If else statement assigns strings to the user's choice of int
if(tempLength == 1)
{
noteLength = "whole";
}
else if(tempLength == 2)
{
noteLength = "half";
}
else if(tempLength == 3)
{
noteLength = "quarter";
}
else if(tempLength == 4)
{
noteLength = "eighth";
}
else if(tempLength == 5)
{
noteLength = "sixteenth";
}
else
{
noteLength = "Invalid";
}
//Create demoNote object
Note demoNote = new Note(noteValue, noteLength);
//Print user the information about their note
System.out.print("Your value was " + demoNote.getValue() + ", your length was a(n) " + demoNote.getLength()
+ " note, your note's \nletter value was " + demoNote.getLetter() + " which is a " +
demoNote.getSharp() + " note. \nThe frequency of your" +
" note is " + demoNote.getFreq() + " hz." );
}
}
class Note
{
/*Declare variables privately so they cannot be accessed from outside the class. Set the value default
to middle C and the length default to quarter.*/
private double value = 0;
private String length = "Quarter";
private String letter;
private String sharp;
private double freq;
/**
* Constructor
* @param value the note's starting value
* @param length the note's starting length
*/
public Note(double value, String length)
{
this.value = value;
this.length = length;
}
//Setters
//Assigns this.value to variable value
void setValue(double value)
{
this.value = value;
}
//Assigns this.length to variable length
void setLength(String x)
{
this.length = length;
}
//Getters
//@return The value of the note
public double getValue()
{
return value;
}
//@return The length of the note
public String getLength()
{
return length;
}
//@return The letter of the chromatic scale the value is assigned to
public String getLetter()
{
if(value == 0 || value == 12 || value == 24 || value == 36 ||
value == -12 || value == -24 || value == -36 || value == -48)
{
letter = "A";
}
else if(value == 1 || value == 13 || value == 25 || value == 37 ||
value == -11 || value == -23 || value == -35 || value == -47)
{
letter = "A#";
}
else if(value == 2 || value == 14 || value == 26 || value == 38 ||
value == -10 || value == -22 || value == -34 || value == -46)
{
letter = "B";
}
else if(value == 3 || value == 15 || value == 27 || value == 39 ||
value == -9 || value == -21 || value == -33 || value == -45)
{
letter = "C";
}
else if(value == 4 || value == 16 || value == 28 || value == -8 ||
value == -20 || value == -32 || value == -44)
{
letter = "C#";
}
else if(value == 5 || value == 17 || value == 29 || value == -7 ||
value == -19 || value == -31 || value == -43)
{
letter = "D";
}
else if(value == 6 || value == 18 || value == 30 || value == -6 ||
value == -18 || value == -30 || value == -42)
{
letter = "D#";
}
else if(value == 7 || value == 19 || value == 31 || value == -5 ||
value == -17 || value == -29 || value == -41)
{
letter = "E";
}
else if(value == 8 || value == 20 || value == 32 || value == -4 ||
value == -16 || value == -28 || value == -40)
{
letter = "F";
}
else if(value == 9 || value == 21 || value == 33 || value == -3 ||
value == -15 || value == -27 || value == - 39)
{
letter = "F#";
}
else if(value == 10 || value == 22 || value == 34 || value == -2 ||
value == -14 || value == -26 || value == -38)
{
letter = "G";
}
else if(value == 11 || value == 23 || value == 35 || value == -1 ||
value == -13 || value == -25 || value == -36)
{
letter = "G#";
}
else
{
letter = "invalid";
}
return letter;
}
//@return Whether or not the note is sharp
public String getSharp()
{
if(value == 1 || value == 13 || value == 25 || value == 37 ||
value == -11 || value == -23 || value == -35 || value == -47 ||
value == 4 || value == 16 || value == 28 || value == -8 ||
value == -20 || value == -32 || value == -44 ||
value == 6 || value == 18 || value == 30 || value == -6 ||
value == -18 || value == -30 || value == -42 ||
value == 9 || value == 21 || value == 33 || value == -3 ||
value == -15 || value == -27 || value == - 39 ||
value == 11 || value == 23 || value == 35 || value == -1 ||
value == -13 || value == -25 || value == -36)
{
sharp = "sharp";
}
else
{
sharp = "natural";
}
return sharp;
}
//@return The frequency of the note
public double getFreq()
{
freq = (440 * Math.pow(2, value / 12));
return freq;
}
}In: Computer Science