Search results for 'ITS'
-
PRG 211 Week 3 Labs
Regular Price: $15.00
Special Price $12.00
PRG 211 Week 3 Labs
Lab 7.1 Loops Convert to binary
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
As long as x is greater than 0
Output x % 2 (remainder is either 0 or 1)
x = x / 2
Note: The above algorithm outputs the 0's and 1's in reverse order.Ex: If the input is 6, the output is:
011
(6 in binary is 110; the algorithm outputs the bits in reverse).
Lab 7.2 Loops Varied amount of input dataStatistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics.
Ex: When the input is 15 20 0 5 -1, the output is:
10 20
You can assume that at least one non-negative integer is input.
Lab 7.3 Loops Output range with increment of 10Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer.
Ex: If the input is -15 30, the output is:
-15 -5 5 15 25Ex: If the second integer is less than the first as in 20 5, the output is:
Second integer can't be less than the first.For coding simplicity, output a space after every integer, including the last.
Lab 7.4 Loops Countdown until matching digitsWrite a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical.
Ex: If the input is 93, the output is:
93 92 91 90 89 88Ex: If the input is 77, the output is:
77Ex: If the input is not between 20 and 98 (inclusive), the output is:
Input must be 20-98For coding simplicity, follow each output number by a space, even the last one. Use a while loop. Compare the digits; do not write a large if-else for all possible same-digit numbers (11, 22, 33, ..., 88), as that approach would be cumbersome for large ranges.
Learn More -
PRG 211 Week 1 Labs
Regular Price: $15.00
Special Price $12.00
Lab 3.1 Formatted Output Hello World!
Write a program the outputs 'Hello World!'
Lab 3.2 Formatted output: No parking sign.Write a program that prints a formatted "No parking" sign. Note the first line has two leading spaces.
NO PARKING
1:00 - 5:00 a.m.
Lab 3.3 House real estate summarySites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (currentPrice * 0.045) / 12.
Ex: If the input is 200000 210000, the output is:
This house is $200000. The change is $-10000 since last month.
The estimated monthly mortgage is $750.0.
Note: Getting the precise spacing, punctuation, and newlines exactly right is a key point of this assignment. Such precision is an important part of programming.
Lab 3.4 Caffeine levelsA half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours in humans. Given caffeine amount (in mg) as input, output the caffeine level after 6, 12, and 18 hours.
Ex: If the input is 100, the output is:
After 6 hours: 50.0 mg
After 12 hours: 25.0 mg
After 18 hours: 12.5 mg
Note: A cup of coffee has about 100 mg. A soda has about 40 mg. An "energy" drink (a misnomer) has between 100 mg and 200 mg.
Lab 3.5 Divide by x.Write a program using integers userNum and x as input, and output userNum divided by x four times.
Ex: If the input is 2000 2, the output is:
1000 500 250 125
Note: In Coral, integer division discards fractions. Ex: 6 / 4 is 1 (the 0.5 is discarded).
Lab 3.6 Driving costs.Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.
Ex: If the input is 20.0 3.1599, the output is:
1.57995 7.89975 63.198
Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. First use the dollars/gallon and miles/gallon values to calculate the dollars/mile. Then use the dollars/mile value to determine the cost per 10, 50, and 400 miles.Note: Real per-mile cost would also include maintenance and depreciation.
Lab 3.7 Simple statistics.Part 1
Given 3 integers, output their average and their product, using integer arithmetic.Ex: If the input is 10 20 5, the output is:
11 1000
Note: Integer division discards the fraction. Hence the average of 10 20 5 is output as 11, not 11.666666666666666.Submit the above for grading. Your program will fail the test cases (which is expected), until you complete part 2 below but check that you are getting the correct average and product using integer division.
Part 2
Also output the average and product, using floating-point arithmetic.Ex: If the input is 10 20 5, the output is:
11 1000
11.666666666666666 1000.0
Lab 3.8 Using math functionsGiven three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolute value of x, and the square root of (xy to the power of z).
Ex: If the input is 5.0 6.5 3.2, the output is:
34938.56214843421 1.2995143401732918e+279 5.0 262.42993783925596
Hint: Coral has built-in math functions (discussed elsewhere) that may be used.
Learn More
Function Behavior Example
SquareRoot(x) Square root of x SquareRoot(9.0) evaluates to 3.0.
RaiseToPower(x, y) Raise x to power y: RaiseToPower(6.0, 2.0) evaluates to 36.0.
AbsoluteValue(x) Absolute value of x AbsoluteValue(-99.5) evaluates to 99.5. -
DAT/210 Week 4 Python LAB 5.22: Phone number breakdown
Regular Price: $7.00
Special Price $3.00
DAT/210 Week 4 Python LAB 5.22: Phone number breakdown
Given an integer representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-1212.
Ex: If the input is: 8005551212
the output is: (800) 555-1212Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2 digits of 572 is gotten by 572 % 100, which is 72.
Hint: Use // to shift right by the desired amount. Ex: Shifting 572 right by 2 digits is done by 572 // 100, which yields 5. (Recall integer division discards the fraction).
For simplicity, assume any part starts with a non-zero digit. So 0119998888 is not allowed.main.py
Learn More
phone_number = int(input())
''' Type your code here. ''' -
DAT/210 Week 4 Python LAB 5.21: Expression for calories burned during workout
Regular Price: $7.00
Special Price $3.00
DAT/210 Week 4 Python LAB 5.21: Expression for calories burned during workout
The following equations estimate the calories burned when exercising (source):
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.184Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for women and men.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print( 'Men: {:.2f} calories'.format(calories_man))Ex: If the input is:
49 155 148 60
Then the output is:
Women: 580.94 calories
Men: 891.47 calories
Learn More
main.py
''' 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 '''
''' Type your code here. ''' -
DAT/210 Week 4 Python LAB 5.20: Simple statistics
Regular Price: $7.00
Special Price $3.00
DAT/210 Week 4 Python LAB 5.20: Simple statistics
Given 4 floating-point numbers. Use a string formatting expression with conversion specifiers to output their product and their average as integers (rounded), then as floating-point numbers.
Output each rounded integer using the following:
print( '{:.0F}'.format(your_value))
Output each floating-point value with three digits after the decimal point, which can be achieved as follows:
print( '{:.3F}'.format(your_value))Ex: If the input is:
8.3
10.4
5.0
4.8
the output is:
2072 7
2071.680 7.125
Learn More
main.py
numl = float(input())
num2 = float(input())
num3 = float(input())
num4 = float(input())
''' Type your code here. ''' -
DAT/210 Week 2 Java LAB 3.21: Interstate highway numbers
Regular Price: $7.00
Special Price $3.00
DAT/210 Week 2 Java LAB 3.21: Interstate highway numbers
Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. Auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. Thus, I-405 services I-5, and I-290 services I-90.
Given a highway number, indicate whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also indicate if the (primary) highway runs north/south or east/west.Ex: If the input is:
90
the output is:
I-90 is primary, going east/west.Ex: If the input is:
290 the output is:
1-290 is auxiliary, serving 1-90, going east/west.Ex: If the input is:
0
or any number not between 1 and 999,
the output is:
0 is not a valid interstate highway number.See Wikipedia for more info on highway numbering.
import java.util.Scanner;
public class LabProgram {
Learn More
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int highwayNumber;
int primaryNumber;
highwayNumber = scnr.nextInt();
/* Type your code here. */
}
} -
DAT/210 Week 2 Java LAB 3.18: Driving costs
Regular Price: $7.00
Special Price $3.00
DAT/210 Week 2 Java LAB 3.18: Driving costs
Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
System.out.printf("%.2f", yourValue);
The output ends with a newline.Ex: If the input is:
20.0 3.1599
the output is:
3.16 11.85 79.00Note: Real per-mile cost would also include maintenance and depreciation.
import java.util.Scanner;
public class LabProgram {
Learn More
public static void main(String() args) {
/* Type your code here. */
}
} -
PRG/211 Week 3 Lab 7.4 Loops: Countdown until matching digits
Regular Price: $8.00
Special Price $3.00
PRG/211 Week 3 Lab 7.4 Loops: Countdown until matching digits
Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical.
Ex: If the input is 93, the output is:
93 92 91 90 89 88Ex: If the input is 77, the output is:
77Ex: If the input is not between 20 and 98 (inclusive), the output is:
Input must be 20-98For coding simplicity, follow each output number by a space, even the last one. Use a while loop. Compare the digits; do not write a large if-else for all possible same-digit numbers (11, 22, 33, ..., 88), as that approach would be cumbersome for large ranges.
Learn More -
PRG/211 Week 3 Lab 7.1 Loops: Convert to binary
Regular Price: $8.00
Special Price $3.00
PRG/211 Week 3 Lab 7.1 Loops: Convert to binary
Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:
As long as x is greater than 0
Output x % 2 (remainder is either 0 or 1)
x = x / 2
Note: The above algorithm outputs the 0's and 1's in reverse order.Ex: If the input is 6, the output is:
Learn More
011
(6 in binary is 110; the algorithm outputs the bits in reverse). -
PRG/211 Week 1 Lab 3.4: Caffeine levels
Regular Price: $8.00
Special Price $3.00
PRG/211 Week 1 Lab 3.4.1: Caffeine levels
A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours in humans. Given caffeine amount (in mg) as input, output the caffeine level after 6, 12, and 18 hours.
Ex: If the input is 100, the output is:
After 6 hours: 50.0 mg
Learn More
After 12 hours: 25.0 mg
After 18 hours: 12.5 mg
Note: A cup of coffee has about 100 mg. A soda has about 40 mg. An "energy" drink (a misnomer) has between 100 mg and 200 mg.