Answer:
In Java:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
float speedlimit, actualspeed;
String ddate;
int schoolzone;
System.out.print("Speed Limit: ");
speedlimit = input.nextFloat();
System.out.print("Actual Speed: ");
actualspeed = input.nextFloat();
System.out.print("Date: ");
ddate = input.nextLine();
System.out.print("School Zone (1-Yes): ");
schoolzone = input.nextInt();
float ticket = 75;
ticket += 6 * (actualspeed - speedlimit);
if(actualspeed - speedlimit > 30){
ticket+=160;
}
if(schoolzone == 1){
ticket*=2;
}
System.out.print("Date: "+ddate);
System.out.print("Speed Limit: "+speedlimit);
System.out.print("Actual Speed: "+actualspeed);
System.out.print("Ticket: "+ticket);
}
}
Explanation:
See attachment for complete program requirements
This declares speedlimit and actualspeed as floats
float speedlimit, actualspeed;
This declares ddate as string
String ddate;
This declares schoolzone as integer
int schoolzone;
This prompts the user for speed limit
System.out.print("Speed Limit: ");
This gets the speed limit
speedlimit = input.nextFloat();
This prompts the user for actual speed
System.out.print("Actual Speed: ");
This gets the actual speed
actualspeed = input.nextFloat();
This prompts the user for date
System.out.print("Date: ");
This gets the date
ddate = input.nextLine();
This prompts the user for school zone (1 means Yes, other inputs means No)
System.out.print("School Zone (1-Yes): ");
This gets the input for schoolzone
schoolzone = input.nextInt();
This initializes ticket to $75
float ticket = 75;
This calculates the additional cost based on difference between speed limits and the actual speed
ticket += 6 * (actualspeed - speedlimit);
If the difference between the speeds is greater than 30, this adds 160 to the ticket
if(actualspeed - speedlimit > 30){
ticket+=160;
}
If it is in a school zone, this doubles the ticket
if(schoolzone == 1){
ticket*=2;
}
The following print the ticket information
System.out.print("Date: "+ddate);
System.out.print("Speed Limit: "+speedlimit);
System.out.print("Actual Speed: "+actualspeed);
System.out.print("Ticket: "+ticket);
Play now? Play later?
You can become a millionaire! That's what the junk mail said. But then there was the fine print:
If you send in your entry before midnight tonight, then here are your chances:
0.1% that you win $1,000,000
75% that you win nothing
Otherwise, you must PAY $1,000
But wait, there's more! If you don't win the million AND you don't have to pay on your first attempt,
then you can choose to play one more time. If you choose to play again, then here are your chances:
2% that you win $100,000
20% that you win $500
Otherwise, you must PAY $2,000
What is your expected outcome for attempting this venture? Solve this problem using
a decision tree and clearly show all calculations and the expected monetary value at each node.
Use maximization of expected value as your decision criterion.
Answer these questions:
1) Should you play at all? (5%) If you play, what is your expected (net) monetary value? (15%)
2) If you play and don't win at all on the first try (but don't lose money), should you try again? (5%) Why? (10%)
3) Clearly show the decision tree (40%) and expected net monetary value at each node (25%)
Answer:
wow what a scam
Explanation:
Create a program that writes a series of random numbers to a file, then reads the file to calculate the average of those numbers, as well as the highest and lowest numbers. Prompt the user for how many random numbers they want to add to file. If the number is less than 100, add at least 100 numbers. Each random number should be between 10 and 500, inclusive (at least 10, no more than 500). Create the file as YourName_randomnumbers.txt (where YourName is your actual name or initials...) Once the program creates the file, open and read in all numbers. Loop through the numbers and determine the highest number, the lowest number, count how many entries are in the file, and calculate the average of all numbers. Remember to use functions and comment as needed. Submit your .py file and your randomnumbers.txt file.
Answer:
In Python:
import random
def average(content):
sum = 0
for i in range(0, len(content)):
content[i] = int(content[i])
sum = sum + content[i]
print("Average: "+str(round(sum/len(content),2)))
def maxList(content):
print("Highest: "+str(max(content)))
def minList(content):
print("Lowest: "+str(min(content)))
f = open("YourName_randomnumbers.txt", "w")
num = int(input("Random Numbers: "))
if num < 100:
num = 100
for i in range(1,num+1):
f.write(str(random.randint(10,500)))
f.write(" ")
f.close()
with open('YourName_randomnumbers.txt') as ff:
content = ff.read().split()
print("Entries: "+str(len(content)))
average(content)
maxList(content)
minList(content)
Explanation:
First, we import the random module
import random
The program uses functions. The first is the average function
def average(content):
This initializes sum to 0
sum = 0
This iterates through the list and adds up the list elements
for i in range(0, len(content)):
content[i] = int(content[i])
sum = sum + content[i]
This prints the average, rounded to 2 decimal places
print("Average: "+str(round(sum/len(content),2)))
The maxList function begins here
def maxList(content):
This gets and prints the highest of the list
print("Highest: "+str(max(content)))
The minList function begins here
def minList(content):
This gets and prints the lowest of the list
print("Lowest: "+str(min(content)))
The main begins here
This createa a file and prepares it for write operations
f = open("YourName_randomnumbers.txt", "w")
This prompts user for number of random numbers
num = int(input("Random Numbers: "))
If user input is less than 100
if num < 100:
It is set to 100
num = 100
The following iteration generates random numbers between 10 and 500 and inserts the random number to file
for i in range(1,num+1):
f.write(str(random.randint(10,500)))
f.write(" ")
Close file
f.close()
The following iteration reads the file content into a list
with open('YourName_randomnumbers.txt') as ff:
content = ff.read().split()
This prints the number of entries
print("Entries: "+str(len(content)))
The next three instructions calls the average, maxList and minList functions respectively
average(content)
maxList(content)
minList(content)
A marketing plan includes a number of factors, including the marketing mix.
What is the marketing mix?
A. The variables of product, price, place, and promotion
B. Using names and symbols to ideny the company's products
C. How the company intends for customers to view its product
relative to the competition
D. A plan for spending money
SUBMIT
— If NOT temp == 32.0 Then. Set temp = 32.0. End If.
What is the error
Answer:
im sorry so sorry i needed the pts
Explanation:
Giving brainliest if you answer question.
What is a good slogan for digital citizenship?
Answer:
No matter where you are in the world you have a place to go to
Explanation:
In this world of globalization it makes sense you would be anywhere in the world and still have a place to go to.
Answer:
"If you are on social media, and you are not learning, not laughing, not being inspired or not networking, then you are using it wrong."
Explanation: (this is the freedom of speech not my words.) but there true even though and that we all (i dont know if its everyone but y'know) have to stay inside during this pandemic try to make the most of it!
List the three ways Python can handle colors.
Answer:
Try using coloramapackage in python for text colour & has cross platform support across Windows & Linux. It can also be used in conjunction with existing ANSI libraries like Termcolor. This approach would be better than manually printing ASCII sequences for text colouring on terminals. from colorama import Fore, Back, Style
Explanation:
A(an)_______is built-in preset calculation.
formula
function
equation
AutoSum
Answer:
Hello! The answer to your question is function I had the same question and got it right!
Explanation:
Hope this helped:)
Changing the color of the text in your document is an example of
Answer:
???????????uhhh text change..?
Explanation:
Answer:
being creative
Explanation:
cause y not?
the keyboard,mouse, display,and system units are:
Answer:
input devices?
Explanation:
Keyboard: It is used to give input through typing of the keys in keyboard. Mouse: It is used to give input through clicking mouse or selecting the options. System unit: It collectively defines the motherboard and CPU of the computer.
The keyboard, mouse, display, and system units are the four main components of a computer system.
Given that,
The devices are Keyboard, Mouse, Display, and System units.
A computer comprises hardware and software.
The hardware is the devices that are used for the input and output of the data.
The software is the devices that are integrated into the devices of the computer. This processes the data and provides the result.
The output devices show the result of our actions on the computer. Example: Screen.
The storage devices are used to store the data which are given as input. Example: Hard disk.
Thus, these all come under the hardware devices of the computer.
Read more on computer hardware here:
brainly.com/question/959479
#SPJ6
Write a program with the total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. The input should be an integer, with the unit as "cents". For example, the input of 126 refers to 126 cents. 1 Dollar = 100 cents 1 Quarter = 25 cents 1 Dime = 10 cents 1 Nickel = 5 cents 1 Penny = 1 cent Ex: If the input is:
Answer:
In Python:
cents = int(input("Cents: "))
dollars = int(cents/100)
quarters = int((cents - 100*dollars)/25)
dimes = int((cents - 100*dollars- 25*quarters)/10)
nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)
pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels
if not(dollars == 0):
if dollars > 1:
print(str(dollars)+" dollars")
else:
print(str(dollars)+" dollar")
if not(quarters == 0):
if quarters > 1:
print(str(quarters)+" quarters")
else:
print(str(quarters)+" quarter")
if not(dimes == 0):
if dimes > 1:
print(str(dimes)+" dimes")
else:
print(str(dimes)+" dime")
if not(nickels == 0):
if nickels > 1:
print(str(nickels)+" nickels")
else:
print(str(nickels)+" nickel")
if not(pennies == 0):
if pennies > 1:
print(str(pennies)+" pennies")
else:
print(str(pennies)+" penny")
Explanation:
A prompt to input amount in cents
cents = int(input("Cents: "))
Convert cents to dollars
dollars = int(cents/100)
Convert the remaining cents to quarters
quarters = int((cents - 100*dollars)/25)
Convert the remaining cents to dimes
dimes = int((cents - 100*dollars- 25*quarters)/10)
Convert the remaining cents to nickels
nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)
Convert the remaining cents to pennies
pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels
This checks if dollars is not 0
if not(dollars == 0):
If greater than 1, it prints dollars (plural)
if dollars > 1:
print(str(dollars)+" dollars")
Otherwise, prints dollar (singular)
else:
print(str(dollars)+" dollar")
This checks if quarters is not 0
if not(quarters == 0):
If greater than 1, it prints quarters (plural)
if quarters > 1:
print(str(quarters)+" quarters")
Otherwise, prints quarter (singular)
else:
print(str(quarters)+" quarter")
This checks if dimes is not 0
if not(dimes == 0):
If greater than 1, it prints dimes (plural)
if dimes > 1:
print(str(dimes)+" dimes")
Otherwise, prints dime (singular)
else:
print(str(dimes)+" dime")
This checks if nickels is not 0
if not(nickels == 0):
If greater than 1, it prints nickels (plural)
if nickels > 1:
print(str(nickels)+" nickels")
Otherwise, prints nickel (singular)
else:
print(str(nickels)+" nickel")
This checks if pennies is not 0
if not(pennies == 0):
If greater than 1, it prints pennies (plural)
if pennies > 1:
print(str(pennies)+" pennies")
Otherwise, prints penny (singular)
else:
print(str(pennies)+" penny")
What is the value of the variable answer after the following code is executed?
String strl = "apple", str2 = "banana";
boolean answer = stri.equals(str2) && (stri.length() < str2.length());
true
false
Answer:
false
Explanation:
String[][] arr = {{"Hello,", "Hi,", "Hey,"}, {"it's", "it is", "it really is"}, {"nice", "great", "a pleasure"},
{"to", "to get to", "to finally"}, {"meet", "see", "catch up with"},
{"you", "you again", "you all"}};
for (int j = 0; j < arr.length; j++) {
for (int k = 0; k < arr[0].length; k++) {
if (k == 1) { System.out.print(arr[j][k] + " ");
}
}
}
What, if anything, is printed when the code segment is executed?
Answer:
Explanation:
The code that will be printed would be the following...
Hi, it is great to get to see you again
This is mainly due to the argument (k==1), this argument is basically stating that it will run the code to print out the value of second element in each array within the arr array. Therefore, it printed out the second element within each sub array to get the above sentence.
When the code segment is executed, the output is "Hi, it is great to get to see you again "
In the code segment, we have the following loop statements
for (int j = 0; j < arr.length; j++) {for (int k = 0; k < arr[0].length; k++) {The first loop iterates through all elements in the array
The second loop also iterates through all the elements of the array.
However, the if statement ensures that only the elements in index 1 are printed, followed by a space
The elements at index 1 are:
"Hi," "it" "is" "great" "to" "get" "to" "see" "you" "again"
Hence, the output of the code segments is "Hi, it is great to get to see you again "
Read more about loops and conditional statements at:
https://brainly.com/question/26098908
Define the _make method, which takes one iterable argument (and no self argument: the purpose of _make is to make a new object; see how it is called below); it returns a new object whose fields (in the order they were specified) are bound to the values in the interable (in that same order). For example, if we called Point._make((0,1)) the result returned is a new Point object whose x attribute is bound to 0 and whose y attribute is bound to 1.
We can actually see that the _make method is known to be a function that creates named tuple type.
What is _make method?_make method is seen in Python programming which is used to create a named tuple type instantly. It can be used for conversion of objects e.gtuple, list, etc. to named tuple.
Thus, we see the definition of _make method.
Learn more about Python on https://brainly.com/question/26497128
#SPJ2
A car dealership needs a program to store information about the cars for sale. For each car, they want to keep track of the following information number of doors (2 or 4), whether the car has air conditioning, and its average number of miles per gallon. Which of the following is the best design?
a. Use classes: Doors, Airconditioning, and MilesPerGallon, each with a subclass Car.
b. Use a class Car, with subclasses of Doors, Airconditioning, and MilesPerGallon.
c. Use a class Car with three subclasses: Doors, Airconditioning, and MilesPerGallon.
d. Use a class Car, with fields: numDoors, hasAir, and milesPerGallon.
e. Use four unrelated classes: Car, Doors, Airconditioning, and MilesPerGallon.
Answer:
The answer is "Choice d".
Explanation:
In this topic, the option d, which is "Use a class Car, with fields: numDoors, hasAir, and milesPerGallon" is right because the flag, if air-conditioned, of its numbers of doors, was its average kilometers per gallon, qualities of either an automobile, in which each one is a basic value so that they're being fields of a class of cars.
The best design for the given program will be;
D: Use a class Car, with fields: numDoors, hasAir, and milesPerGallon.
What is the best design for the program?In this question, the best design for the program to keep track of the number of doors (2 or 4), whether the car has air conditioning, and its average number of miles per gallon is to "Use a class Car, with fields: numDoors, hasAir, and milesPerGallon"
That option is right because has classified the cars with the accurate parameters to be searched which are its numbers of doors, average miles per gallon, air condition.
Read more about programming at; https://brainly.com/question/22654163
what does coding mean
Answer: Computer coding is the use of computer programming languages to give computers and machines a set of instructions on what actions to perform. It's how humans communicate with machines. It's what allows us to create computer software like programs, operating systems, and mobile apps.
Explanation: I hope that helps
Consider this scenario: A major software company finds that code has been executed on an infected machine in its operating system. As a result, the company begins working to manage the risk and eliminates the vulnerability 12 days later. Which of the following statements best describes the company’s approach?
Answer:
The company effectively implemented patch management.
Explanation:
From the question we are informed about a scenario whereby A major software company finds that code has been executed on an infected machine in its operating system. As a result, the company begins working to manage the risk and eliminates the vulnerability 12 days later. In this case The company effectively implemented patch management. Patch management can be regarded as process involving distribution and application of updates to software. The patches helps in error correction i.e the vulnerabilities in the software. After the release of software, patch can be used to fix any vulnerability found. A patch can be regarded as code that are used in fixing vulnerabilities
Veronica is looking for a reliable website with information about how old you have to be to use social media. What should she look for?
Answer:
The URL of the website
Explanation:
Look for .gov and .edu as they are often reliable sources
g Write a program that reads a list of words, and a character. The output of the program is every word in the list of words that contains the character at least once. For coding simplicity, follow each output word by a comma, even the last one. Assume at least one word in the list will contain the given character. The number of input words is always less than and equal to 10. If the user enters more than 10 words before the character, the program will output Too many words and exit.
Answer:
Here you go, alter this as you see fit :)
Explanation:
array = []
cnt = 0
while cnt < 11:
x = input("Enter a word: ")
array.append(x)
cnt += 1
y = input("Add another word?(Y/n): ")
if y.lower() == "n":
break
letter = input("\nChoose a letter: ")
if len(letter) != 1:
print("Error: too many characters")
quit()
for n in range(len(array)):
if letter.lower() in array[n].lower():
print(array[n], end= ",")
what 80s Disney movie was called the movie that nearly killed Disney? P.S. look it up
Answer:
The black cauldron
Explanation:
it was the most expensive animated film of its time ever made
Answer: The Black Couldren.
Explanation:
Does modern technology make our lives better,worse ,or doesn’t really make a change in your life ?Whats your opinion ?
Find an overall minimum two-level circuit (corresponding to sum of products expressions) using multiple AND and one multi-input OR gate per function for the following set of functions. Show a K-map for each function, and draw the final two-level circuit. You will have to share terms between F and G to find the minimum circuit.
F(a, b, c, d) = m(0, 1, 2, 3, 6, 7, 8, 10, 12, 13)
G(a, b, c, d) = {m(0, 1, 2, 3, 8, 9, 10, 13)
Answer:
si la pusiera en español te pudiera responer
You may have come across websites that not only ask you for a username and password, but then ask you to answer pre-selected personal questions about yourself. What can you conclude about this procedure and how it may increase your security?
Answer:
The questions are used to secure and identify you furthermore. Answering personal questions that only you can answer will deter someone from hacking into your account that easily.
Explanation:
The return value is a one-dimensional array that contains two elements. These two elements indicate the rows and column indices of the largest element in the two-dimensional array. Write a test program that prompts the user to enter a two-dimensional array and displays the location of the largest element in the array.
Answer:
In Java:
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int row, col;
System.out.print("Rows: "); row = input.nextInt();
System.out.print("Cols: "); col = input.nextInt();
int[][] Array2D = new int[row][col];
System.out.print("Enter array elements: ");
for(int i =0;i<row;i++){
for(int j =0;j<col;j++){
Array2D[i][j] = input.nextInt();
} }
int[] maxarray = findmax(Array2D,row,col);
System.out.println("Row: "+(maxarray[0]+1));
System.out.println("Column: "+(maxarray[1]+1));
}
public static int[] findmax(int[][] Array2D,int row, int col) {
int max = Array2D[0][0];
int []maxitem = new int [2];
for(int i =0;i<row;i++){
for(int j =0;j<col;j++){
if(Array2D[i][j] > max){
maxitem[0] = i;
maxitem[1] = j; } } }
return maxitem;
}
}
Explanation:
The next two lines import the scanner and array libraries
import java.util.Scanner;
import java.util.Arrays;
The class of the program
public class Main {
The main method begins here
public static void main(String args[]) {
The scanner function is called in the program
Scanner input = new Scanner(System.in);
This declares the array row and column
int row, col;
This next instructions prompt the user for rows and get the row input
System.out.print("Rows: "); row = input.nextInt();
This next instructions prompt the user for columns and get the column input
System.out.print("Cols: "); col = input.nextInt();
This declares the 2D array
int[][] Array2D = new int[row][col];
This prompts the user for array elements
System.out.print("Enter array elements: ");
The following iteration populates the 2D array
for(int i =0;i<row;i++){
for(int j =0;j<col;j++){
Array2D[i][j] = input.nextInt();
} }
This calls the findmax function. The returned array of the function is saved in maxarray
int[] maxarray = findmax(Array2D,row,col);
This prints the row position
System.out.println("Row: "+(maxarray[0]+1));
This prints the column position
System.out.println("Column: "+(maxarray[1]+1));
The main method ends here
}
The findmax function begins here
public static int[] findmax(int[][] Array2D,int row, int col) {
This initializes the maximum to the first element of the array
int max = Array2D[0][0];
This declares maxitem. The array gets the position of the maximum element
int []maxitem = new int [2];
The following iteration gets the position of the maximum element
for(int i =0;i<row;i++){
for(int j =0;j<col;j++){
if(Array2D[i][j] > max){
maxitem[0] = i; -- The row position is saved in index 0
maxitem[1] = j; -- The column position is saved in index 1} } }
This returns the 1 d array
return maxitem;
}
Compression algorithms vary in how much they can reduce the size of a document.
Which of the following would likely be the hardest to compress?
Choose 1 answer:
A. The Declaration of Independence
B. The lyrics to all of the songs by The Beatles
C. A document of randomly generated letters
D. A book of nursery rhymes for children
The statement that represents the thing that would likely be the hardest to compress is a document of randomly generated letters. Thus, the most valid option for this question is C.
What is an Algorithm?An algorithm may be characterized as a type of methodology that is significantly utilized for solving a problem or performing a computation with respect to any numerical problems.
According to the context of this question, an algorithm is a set of instructions that allows a user to perform solutions with respect to several numerical and other program-related queries. It can significantly act as an accurate list of instructions that conduct particular actions step by step in either hardware- or software-based routines.
Therefore, the statement that represents the thing that would likely be the hardest to compress is a document of randomly generated letters. Thus, the most valid option for this question is C.
To learn more about Algorithms, refer to the link:
https://brainly.com/question/24953880
#SPJ3
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems. A. procedural abstraction B. API C. modularity D. library
Answer:
procedural abstraction
Explanation:
The term that refers to a solution to a large problem that is based on the solutions of smaller subproblems is A. procedural abstraction.
Procedural abstraction simply means writing code sections that are generalized by having variable parameters.
Procedural abstraction is essential as it allows us to think about a framework and postpone details for later. It's a solution to a large problem that is based on the solutions of smaller subproblems.
Read related link on:
https://brainly.com/question/12908738
What is the output of the following code snippet if the variable named cost contains 100? if cost < 70 or cost > 150 : discount = 0.8 * cost else : discount = cost print("Your cost is ", discount)
Answer:
The output is: Your cost is 100
Explanation:
Given
The above code snippet
and
[tex]cost = 100[/tex]
Required
Determine the output of the code
if cost < 70 or cost > 150
The above condition checks if cost is less than 70 or cost is greater than 150
This condition is false because 100 is neither less than 70 nor is it greater than 150
So, the else statement will be executed.
discount = cost
Which means
discount = 100
So, the print instruction will print: Your cost is 100
What’s the difference packet switching and message switching??
Write a function called count_types that returns a dictionary with keys that are Pokemon types and values that are the number of times that type appears in the dataset. The order of the keys in the returned dictionary does not matter. In terms of efficiency, your solution should NOT iterate over the whole dataset once for each type of Pokemon since that would be overly inefficient. For example, assuming we have parsed pokemon_test.csv and stored it in a variable called data:
Answer:
Explanation:
The following code is written in Python. It creates a function called count_types which takes in three parameters. The pokemon in question, the data set, and a dictionary with all the pokemon types and values (Empty to start). Then it simply uses the built-in Python count feature to count the number of times that the Pokemon appears in the data set. Finally it saves that pokemon as a key and count as a value to the dictionary.
def count_types(pokemon, data, my_dict):
count = data.count(pokemon)
my_dict += {pokemon: count}
Robert has opened his own pet supply store so he can help himself to treats and toys whenever he wishes. In order to encourage customers to shop at his store more, he is implementing a customer loyalty program. For every $100 spent, the customer earns a 10% discount on a future purchase. If the customer has earned a discount, that discount will be automatically applied whenever they make a purchase. Only one discount can be applied per purchase. Implement a class Customer that represents a customer in Robert's store.
Answer:
Explanation:
The following code is written in Python and creates a class called customer which holds the customers name, purchase history amount, and current total. It also has 3 functions, a constructor that takes the customer name as a parameter. The add_to_cart function which increases the amount of the current total. And finally the checkout function which applies the available coupon and resets the variables if needed, as well as prints the info the to screen.
class Customer():
customer = ""
purchased_history = 0
current_total = 0
def __init__(self, name):
self.customer = name
def add_to_cart(self, amount):
self.current_total += amount
def checkout(self):
if self.purchased_history >= 100:
self.current_total *= 0.90
self.purchased_history = 0
else:
self.purchased_history += self.current_total
print(self.customer + " current total is: $" + str(self.current_total))
self.current_total = 0