Answer:
Written in C++
int sum(int arr[], int size) {
int total = 0;
if(size>=3) {
for (int i = 0; i < size; ++i) {
if(i%3 == 0) {
total += arr[i];
}
}
}
return total;
}
Explanation:
This line defines the function
int sum(int arr[], int size) {
This line initializes sum to 0
int total = 0;
This line checks if size is at least 3
if(size>=3) {
This loop iterates through the array
for (int i = 0; i < size; ++i) {
The following adds multiples of 3
if(i%3 == 0) {
total += arr[i];
}
}
}
This returns the calculated sum
return total;
}
See attachment for full program
g Write a function called price_of_rocks. It has no parameters. In a while loop, get a rock type and a weight from the user. Keep a running total of the price for all requested rocks. Repeat until the user wants to quit. Quartz crystals cost $23 per pound. Garnets cost $160 per pound. Meteorite costs $15.50 per gram. Assume the user enters weights in the units as above. Return the total price of all of the material. For this discussion, you should first write pseudocode for how you would solve this problem (reference pseudocode.py in the Week 7 Coding Tutorials section for an example). Then write the code for how you would tackle this function. Please submit a Python file called rocks_discussion.py that defines the function (code) and calls it in main().
Answer:
The pseudocode:
FUNCTION price_of_rocks():
SET total = 0
while True:
INPUT rock_type
INPUT weight
if rock_type is "Quartz crystals":
SET total += weight * 23
elif rock_type is "Garnets":
SET total += weight * 160
elif rock_type is "Meteorite":
SET total += weight * 15.50
INPUT choice
if choice is "n":
break
RETURN total
END FUNCTION
The code:
def price_of_rocks():
total = 0
while True:
rock_type = input("Enter rock type: ")
weight = float(input("Enter weight: "))
if rock_type == "Quartz crystals":
total += weight * 23
elif rock_type == "Garnets":
total += weight * 160
elif rock_type == "Meteorite":
total += weight * 15.50
choice = input("Continue? (y/n) ")
if choice == "n":
break
return total
print(price_of_rocks())
Explanation:
Create a function named price_of_rocks that does not take any parameters
Initialize the total as 0
Create an indefinite while loop. Inside the loop:
Ask the user to enter the rock_type and weight
Check the rock_type. If it is "Quartz crystals", multiply weight by 23 and add it to the total (cumulative sum). If it is "Garnets", multiply weight by 160 and add it to the total (cumulative sum). If it is "Meteorite", multiply weight by 15.50 and add it to the total (cumulative sum).
Then, ask the user to continue or not. If s/he enters "n", stop the loop.
At the end of function return the total
In the main, call the price_of_rocks and print
Write this program using an IDE. Comment and style the code according to CS 200 Style Guide. Submit the source code files (.java) below. Make sure your source files are encoded in UTF-8. Some strange compiler errors are due to the text encoding not being correct. This lab asks you to create a text game Rock Paper Scissors. The rule of the game: There are two players in this game and they can choose Rock, Paper, or Scissors each time. Rock beats Scissors, Paper beats Rock and Scissors beat Paper. Your program needs to prompt a user to choose an action (Rock, Paper, or Scissors) and save their choice. The program randomly chooses an action (Hint: use .nextInt() to generate random integers in the range of [1,3]. 1 indicates Rock, 2 indicates Paper and 3 indicates Scissors.) Then the program determines who is the winner.
When input is R Please select one of [R/P/S]: You chose: Rock I chose: Scissors Rock beats scissors - you win! If the user enters the lowercase, your program can still recognize. When input is p Output should be Please select one of [R/P/S]: You chose: Paper I chose: Scissors Scissors beat paper - you lose! If the user enters invalid input, the program will give an error message and set the default choice as Rock When input is v Output should be Please select one of [R/P/S]: Invalid choice! Defaulting to Rock. I chose: Scissors Rock beats scissors - you win! If the user has the same result as the computer, your program should output: A Tie!
Answer:
import java.util.Scanner; //to accept input from user
import java.util.Random; //to generate random numbers
public class Main { //class name
public static void main(String[] args) { //main method
System.out.println("Please select one of [R/P/S]: "); //prompts user to select a choice
Scanner scanner = new Scanner(System.in); //reads input choice
String playerChoice = scanner.next().toUpperCase().replace(" ", ""); //converts the choice to upper case and stores it in playerChoice
if (playerChoice.equals("R") || playerChoice.equals("P") || playerChoice.equals("S")) { // if player choice is a valid choice
results(CompChoice(), playerChoice); // calls method to compute result of game
} else { //if player enters invalid choice
System.out.println("\nInvalid choice!"); } } //error message
private static String CompChoice() { //to generate computer choice
Random generator = new Random(); //to generate random numbers
int comp = generator.nextInt(3)+1; //generates 3 random numbers
String compChoice = ""; //to store computer choice
switch (comp) { //checks the random number for corresponding computer choice
case 1: //1 is for Rock
compChoice = "Rock"; //sets compChoice to Rock
break;
case 2: //random number 2 is for Paper
compChoice = "Paper"; //sets compChoice to Paper
break;
case 3: //random number 3 is for Scissors
compChoice = "Scissors"; //sets compChoice to Scissors
break; }
return compChoice; } //returns computer choice
private static void results(String compChoice, String playerChoice) { //method to compute result
if(playerChoice.equals("R")) //if playerChoice is equal to R
{ playerChoice = "Rock"; //stores Rock to playerChoice
System.out.println("You chose: Rock");} //displays player choice
else if(playerChoice.equals("P")) //if playerChoice is equal to P
{ playerChoice = "Paper"; //stores Paper to playerChoice
System.out.println("You chose: Paper");} //displays player choice
else //if playerChoice is equal to S
{ playerChoice="Scissors"; //stores Scissors to playerChoice
System.out.println("You chose: Scissors"); } //displays player choice
System.out.println("I chose: " + compChoice); //displays computer choice
if (compChoice.equals(playerChoice)) { //if compChoice is equal to playerChoice
System.out.println("a tie!"); //its a tie if computer and player choice is the same
System.exit(1); }//exits on tie
boolean youWin = false; //variable to check if player wins
if (compChoice.equals("Rock")) { //if computer choice is Rock
if (playerChoice.equals("Paper")) //if player choice is Paper
{System.out.println("Paper beats Rock.");
youWin = true;} //player wins to youWin is set to true
else if(playerChoice.equals("Scissors")) { //if player choice is Scissors
System.out.println("Rock beats scissors.");
youWin = false;} } //player loses to youWin is set to false
if (compChoice.equals("Paper")) { //if computer choice is Paper
if (playerChoice.equals("Rock")) //if player choice is Rock
{System.out.println("Paper beats Rock.");
youWin = false;} //player loses to youWin is set to false
else if(playerChoice.equals("Scissors")) { //if player choice is Scissors
System.out.println("Scissors beats Paper.");
youWin = true;} } //player wins to youWin is set to true
if (compChoice.equals("Scissors")) { //if computer choice is Scissors
if (playerChoice.equals("Rock")) //if player choice is Rock
{System.out.println("Rock beats Scissors.");
youWin = true;} //player wins to youWin is set to true
else if(playerChoice.equals("Paper")) { //if player choice is Paper
System.out.println("Scissors beats Paper.");
youWin = false;} } //player loses to youWin is set to false
if (youWin) //if player wins means if youWin is true
System.out.println("you win!"); //declare player to be winner
else //if player loses means if youWin is false
System.out.println("you lose!"); } } //declare player to lose
Explanation:
The program is well explained in the comments attache with each line of program. The program has three methods. One is the main method to start the game and prompts user to enter a choice and converts the user input choice to upper case. One is CompChoice method that generates three random numbers and uses switch statement to set 1 for Rock, 2 for Paper and 3 for Scissors . One method is results that takes computer choice and player choice as parameters to decide the winner. It uses if else statements to check if choice of user wins from choice of computer or vice versa. It uses a boolean variable youWin which is set to true when player choice beats computer choice otherwise is set to false. At the end if youWin is true then the player is declared winner otherwise not. The screenshot of the program output is attached.
Why would a programmer use a web library?
a
to learn about the history of a programming language
b
to quickly insert functions and code into web pages
c
to find books available in their area
d
to see what websites looked like before they were updated
A programmer that uses a web library quickly inserts functions and code into a web page. The correct option is b.
What is a web library?Programming libraries are helpful resources that can speed up the work of a web developer. They offer pre-written, reusable portions of code so that programmers can easily and quickly create apps.
A library is a group of documents, applications, scripts, routines, or other pieces of code that can be used as references in computer programming.
Therefore, the correct option is b. to quickly insert functions and code into web pages.
To learn more about web library, refer to the link:
https://brainly.com/question/30137392
#SPJ1
If a command was taking a large amount of system resources (memory and processing) and this was causing some system performance issues, what could a system administrator do to solve the problem?
Answer:
They can delete some tabs so less resources go to RAM
Explanation:
It depends on how many cores you have, your clock speed etc, when you have a lot of tabs open then your computer sends some files to RAM to be stored for a little while whilst it clears up some of its files. So therefore, delete/move some files so less files can be transported to RAM.
Student Generated Code Assignments Option 1: Write a program that will read in 3 grades from the keyboard and will print the average (to 2 decimal places) of those grades to the screen. It should include good prompts and labeled output. Use the examples from the earlier labs to help you. You will want to begin with a design. The Lesson Set 1 Pre-lab Reading Assignment gave an introduction for a design similar to this problem. Notice in the sample run that the answer is stored in fixed point notation with two decimal points of precision. Sample run: Option 2: The Woody furniture company sells the following three styles of chairs: Style Price Per Chair American Colonial $ 85.00 Modern $ 57.50 French Classical $127.75 Write a program that will input the amount of chairs sold for each style. It will print the total dollar sales of each style as well as the total sales of all chairs in fixed point notation with two decimal places.
Sample run:
Please input the first grade 97
Please Input the second grade 98.3
Please Input the third grade 95
The average of the three grades is 96.77
In python:
first_grade = float(input("Please input the first grade "))
second_grade = float(input("Please input the second grade "))
third_grade = float(input("Please input the third grade "))
print("The average of the three grades is {}".format( round((first_grade + second_grade + third_grade) / 3,2)))
First_ grade = float(input("Please input the first grade ")) and second_ grade = float(input("Please input the second grade ")), third_ grade = float(input("Please input the third grade.
What is Program?A computer utilizes a program, which is a collection of instructions, to carry out a particular task. A program is like a computer's recipe, to use an analogy.
It has a list of components (known as variables, which can stand for text, graphics, or numeric data) and a list of instructions (known as statements), which instruct the computer on how to carry out a certain operation.
Programming languages with particular syntax, like C++, Python, and Ruby, are used to develop programs. These high level programming languages are writing and readable by humans.
Therefore, First_ grade = float(input("Please input the first grade ")) and second_ grade = float(input("Please input the second grade ")), third_ grade = float(input("Please input the third grade.
To learn more Programming, refer to the link:
https://brainly.com/question/11023419
#SPJ2
Your friend is using Internet Explorer to send and receive email using her Hotmail account. She received a Word document attached to an email message from a business associate. She double-clicked the Word attachment and spent a couple of hours editing it, saving the document as she worked. Then she closed the document. But where’s the document now? When she later needed it, she searched her email account online and the Documents folder on her hard drive, but she could not find the document. She called you in a panic asking you to help her find her lost document.
Answer:
Temporary Internet Files folder
Explanation:
Assuming that your friend is using the Microsoft Windows 10 operating system, then this document would have gotten saved in the Temporary Internet Files folder within the operating system. This folder can be located within the following address in the operating system
C:\Users\[username]\AppData\Local\Microsoft\Windows\INetCache
Navigating to this address would help you find the folder and inside that should be the Microsoft Word document that you have used in your Internet Explorer Browser. This folder is where all browser files get saved when they are not explicitly downloaded to a specific folder but are still used within the browser.
Identify the computer cycle in each of the descriptions below by choosing the answer from the
drop-down menus.
The keyboard and mouse are examples of
devices.
The part of the information processing cycle in which raw data is received is known as
The part of the information processing cycle where raw data is converted into meaningful information is
The type of memory used during the processing cycle is
The series of mathematical steps taken by the CPU during processing results in
Answer:
1. Input.
2. An input.
3. Processing.
4. Random Access Memory (RAM).
5. An output.
Explanation:
1. The keyboard and mouse are examples of input devices.
2. The part of the information processing cycle in which raw data is received is known as an input.
3. The part of the information processing cycle where raw data is converted into meaningful information is processing.
4. The type of memory used during the processing cycle is Random Access Memory (RAM).
5. The series of mathematical steps taken by the CPU during processing results in an output.
Answer:
1. Input
2. Input
3. Processing
4. Random Access Memory (RAM)
5. Output
Explanation: Just did it on edge 2023!
Type the correct answer in the box
in which phishing technique are URLs of the spoofed organization misspelled?
anon
is a phishing technique in which URLs of the spoofed organization are misspelled
Answer: Link manipulation
Explanation:
Answer:
Typo Squatting
Explanation:
Reading for comprehension requires _____ reading?
1. passive
2. active
3. slow
4. fast
Answer:
IT is ACTIVE
Explanation: I took the quiz
Answer:
not sure sorry
Explanation:
The best method to prevent information on a disk from being discovered is to: A) use DOD overwrite protocols in wiping information from the disk. B) put the disk and the computer under water. C) melt the plastic disk contained within a hard drive container. D) smash the drive with a stout hammer
Answer:
C) Melt the plastic disk contained within a hard drive container
Explanation:
Data protection is very necessary from keep saving information from those that are not eligible to access it. It helps to avoid phishing scams, and identity theft.Alot of information are stored on the harddisk daily which can be read by disk drive, as situation can warrant prevention of third party from discovering information on it.There is hard platter used in holding magnetic medium in hard disk which make it different from flexible plastic film used in tapes.The disk drive container helps to hold as well power the disk drive.
It should be noted that The best method to prevent information on a disk from being discovered is to firstly
Melt the plastic disk contained within a hard drive container.
C Write 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:
Answer:
Written in C Language
#include <stdio.h>
int main() {
int num1, num2;
printf("Enter two integers: ");
scanf("%d", &num1);
scanf("%d", &num2);
if(num1 <= num2){
for(int i = num1; i<= num2; i+=10)
{
printf("%d",i); printf(" ");
}
}
return 0;
}
Explanation:
This line declares two integer variables
int num1, num2;
This line prompts user for input of the two numbers
printf("Enter two integers: ");
The next two lines get integer input from the user
scanf("%d", &num1);
scanf("%d", &num2);
The following if statement checks if num1 is less than or equal to num2
if(num1 <= num2){
The following iteration prints from num1 to num2 at an increment of 10
for(int i = num1; i<= num2; i+=10)
{
printf("%d",i); printf(" ");
}
PV = 11,000 AC = 6000 CV = 4,000. What is SV? What does this calculation tell you?
Answer:
I don't see an SV in the examples.. I suspect these are the name plate numbers off of a transformer... but.. more context would really help
Explanation:
Two middle-order batsmen are compared based on their performance in their previous cricket match.
Batsman A got 9 runs more than Batsman B and Batsman A's runs are 56% of the sum of both their runs.
What runs did Batsman A and B score, respectively?
Compare the ufw status verbose command output with Windows Firewall with the Advanced Security Windows Firewall Properties you investigated in an earlier lab. Describe the major similarities that you observe.
Answer:
Following are the solution to this question:
Explanation:
Its common factor between both the ufw state glib collection consisted of times more likely Protection View Firewall Property is that they demonstrate the status of the network. So, the consumer sees that path could go to next.
The following are the command which is defined in the attached file.
Which function is used to display a string value to the screen?
print()
main()
run =
Hello, World!
Answer:
print()
Explanation:
The hide/unhide feature only hides in the
_____ view?
Answer: main...?
Explanation:
I don‘t know how to solve a crossword puzzle. Please help me!!!
Activity # 1
Write an algorithm and flowchart that will accept number of days and
displays the equivalent number of months and number of hours.
Where, 1 month has 30 days.
I need an answer for this one please
Answer:
input number of days d
↓
calculate number of months as d/30 rounded up
↓
display number of months
↓
calculate number of hours as d * 24
↓
display number of hours
Explanation:
The flowchart is pretty straightforward since there are no decisions to make.
In much of the world, SI units are used in everyday life and not just in science. Why would it make sense for people in the United States to use SI units in everyday life, too?
Answer:
The use of SI is a way to standardize all measurements.
Explanation:
The use of SI is a way to standardize all measurements. In this way, people all over the world can communicate the data without any confusion. This allows them to exchange quantitative information when it comes to business and science in an effective and convenient way.
Edhesive 3.2 Lesson Practice question 1
value = float(input("Enter a number: "))
if value > 45.6:
print("Greater than 45.6")
I hope this helps!
The program for the given output can be find in the explanation part which will show the answer "greater than 45.6" if the number exceeds than the digit.
What is computer programming?The development of individual pieces of software that allow the entire system to function as a single unit is referred to as systems programming.
Many layers are involved in system programming, including the operating system (OS), firmware, and development environment.
The complexity of the instructions that computers comprehend is the primary reason why programming is considered difficult to learn. You cannot instruct computers in English or any other human language.
Individuals interested in becoming computer programmers must first obtain a degree in computer science, information technology, mathematics, or a related discipline.
value = float(input("Enter a number: "))
if value > 45.6:
print("Greater than 45.6")
Thus, above mentioned is the computer program that will give the required output.
For more details regarding computer programming, visit:
https://brainly.com/question/3397678
#SPJ5
Write a function, maxRadius, to find an index of a Planet with the largest radius in the array. The function should
Answer:
Follows are the code to this question:
#include<iostream>//defining header file
#include<string>//defining header file
using namespace std;
const double Pi =3.141592653589793238463;//defining double constant variable
class Planet
{
private:
string planet_name;//defining string variable
double radius;//defining double variable
public:
Planet()//defining default constructor
{
this->planet_name="";//use this keyword to hold value
this->radius=0.0;//use this keyword to hold value
}
Planet(string name, double radius)//defining parameterized constructor
{
this->planet_name = name;//use this keyword to hold value
this->radius=radius;//use this keyword to hold value
}
string getName() const//defining getName method
{
return this->planet_name;//use return keyword for return string value
}
double getRadius() const//defining getRadius method
{
return this->radius;//use return keyword for return radius value
}
double getVolume() const //defining getVolume method
{
return 4*radius*radius*radius*Pi/3;////use return keyword for return volume value
}
};
int maxRadius(Planet* planets, int s)//defining a method maxRadius that accept two parameter
{
double maxRadius=0;//defining double variable
int index_of_max_radius=-1;//defining integer variable
for(int index=0; index<s; index++)//defining for loop for calculate index of radius
{
if(planets[index].getRadius()>maxRadius)//defining if block to check radius
{
maxRadius = planets[index].getRadius();//use maxRadius to hold value
index_of_max_radius=index;//hold index value
}
}
return index_of_max_radius;//return index value
}
int main()//defining main method
{
Planet planets[5];//defining array as class name
planets[0] = Planet("On A Cob Planet",1234);//use array to assign value
planets[1] = Planet("Bird World",4321);//use array to assign value
int idx = maxRadius(planets,2);//defining integer variable call method maxRadius
cout<<planets[idx].getName()<<endl;//print value by calling getName method
cout<<planets[idx].getRadius()<<endl;//print value by calling getRadius method
cout<<planets[idx].getVolume()<<endl;//print value by calling getVolume method
}
Output:
Bird World
4321
3.37941e+11
Explanation:
please find the complete question in the attached file:
In the above-program code, a double constant variable "Pi" is defined that holds a value, in the next step, a class "Planet" is defined, in the class a default and parameter constructor that is defined that hold values.
In the next step, a get method is used that return value, that is "planet_name, radius, and volume".
In the next step, a method "maxRadius" is defined that accepts two-parameter and calculate the index value, in the main method class type array is defined, and use an array to hold value and defined "idx" to call "maxRadius" method and use print method to call get method.
HELPPPP!!!!
How are unethical practices in the digital sphere the same as or different from such practices in the offline world ?
It might not seem as if these questions have much to do with your future self as a professional, but theydo. Being ethical online is as important to future employers as being ethical in the workplace. Knowingwhat is ethical and thinking about how to handle these situations will affect the way you handle dilemmasthat come up in the professional world. Online behavior is also one way you shape yourself as a personof integrity. Remember,integrityis the quality of being honest and having strong moral principles. Thedigital realm is a very important arena for exercising integrity
Future employers place equal value on online ethics as they do on ethics in the office. You'll be able to handle ethical difficulties that arise in the workplace better if you are aware of them and consider how to approach them.
What are ethics?Ethics are defined as a subfield of philosophy that "systematizes, defends, and counsels conceptions of right and wrong behavior." The Fundamental Ethics Principles. The four ethical tenets are beneficence, nonmaleficence, autonomy, and justice. In order to tell the truth, maintain our word, or assist a stranger in need, we must follow ethical principles.
One method to develop yourself as a person of integrity is through your online behavior. Keep in mind that having integrity means being trustworthy and adhering to high moral standards. The internet world is a crucial space for upholding integrity.
Thus, future employers place equal value on online ethics as they do on ethics in the office. You'll be able to handle ethical difficulties that arise in the workplace better if you are aware of them and consider how to approach them.
To learn more about ethics, refer to the link below:
https://brainly.com/question/11992384
#SPJ2
Works in the public domain have copyright that are expired or abandoned true or false
Answer:
False
Explanation:
Only one of the two are true. Works in the public domain have a copyright that has expired only. E.g. Works of classical music artist, are almost always expired, in accorance with American Copyright law. Abandoning a copyright doesn't do anything because so long the copyright has remained unexpired, the copyright remains. Thats why it can take decades for a new movie in a series to release, like "IT" by Stephen King. The copyright hasn't expired but rather was 'abandoned'. Before "IT" 2017 was relasesed, the copyright was abandoned.
Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain fewer than 20 words.
Ex: If the input is:
5 hey hi Mark hi mark
the output is:
hey 1
hi 2
Mark 1
hi 2
mark 1
Hint: Use two arrays, one array for the strings and one array for the frequencies.
Answer:
Here is the JAVA program:
import java.util.Scanner; //to accept input from user
public class Main { //class name
public static void main(String[] args) { //start of main method
Scanner input = new Scanner(System.in); //creates Scanner object
int integer = input.nextInt(); //declares and reads the integer indicating the number of words
String stringArray[] = new String[integer]; //creates array to hold strings
for (int i = 0; i < integer; i++) { //iterates through the array
stringArray[i] = input.next(); } //reads strings
int frequency[] = new int[integer]; //creates array for frequencies
int count; //declares variable to count frequency of each word
for (int i = 0; i < frequency.length; i++) { //iterates through the frequency array
count = 0; //initializes count to 0
for (int j = 0; j < frequency.length; j++) { //iterates through array
if (stringArray[i].equals(stringArray[j])) { //if element at ith index of stringArray is equal to element at jth index of stringArray
count++; } } //adds 1 to the count
frequency[i] = count; } //adds count to ith index of frequency array
for (int i = 0; i < stringArray.length; i++) { //iterates through the array
System.out.println(stringArray[i] + " " + frequency[i]); } } } //displays each word in stringArray and its corresponding frequency in frequency array
Explanation:
I will explain the program with an example:
let integer = 3
for (int i = 0; i < integer; i++) this loop is used to read input strings into stringArray.
At first iteration:
i = 0
0<3
stringArray[i] = input.next(); this reads a word and stores it to ith index of stringArray. Lets say user enters the string "hey" so hey is stored in stringArray[0]
i++ becomes i = 1
At second iteration:
i = 1
1<3
stringArray[i] = input.next(); this reads a word and stores it to ith index of stringArray. Lets say user enters the string "hi" so hi is stored in stringArray[1]
i++ becomes i = 2
At third iteration:
i = 2
2<3
stringArray[i] = input.next(); this reads a word and stores it to ith index of stringArray. Lets say user enters the string "hi" so hi is stored in stringArray[2]
i++ becomes i = 3
Now the loop breaks as i<integers evaluates to false.
Next the outer loop for (int i = 0; i < frequency.length; i++)
and inner loop for (int j = 0; j < frequency.length; j++) iterate through the array and if condition if (stringArray[i].equals(stringArray[j])) checks if any of the words at specified indices is equal. This is used in order to check if any word in the list comes more than once. So if any word occurs more than once in the array, then its count is increased each time and the count value is stored in frequency[] array to store the count/frequency of each word in the stringArray. Since hey occurs once so its count is set to 1 and hi occurs twice so its frequency is set to 2. So the output of the entire program is:
hey 1
hi 2
hi 2
The screenshot of the program along with its output with the given example in question is attached.
Tony Stark wants to build a 1000 meter high tower as quickly as possible. He has unlimited resources and an unlimited budget and is willing to spend any amount to get the job done.
He has chosen to build the tower with blocks that are 100 meters long and 100 meters wide, but only 1 meter tall. The blocks interlock on top and bottom (like legos). They cannot be stacked sideways.
Using special lifters, putting one block on top of another block takes one week. Putting a stack of up to 100 blocks on top of another stack of 100 or less also takes a week. If either stack is more than 100, it takes two weeks.
What is the shortest amount of time that it will take to build the tower?
Why is your answer the shortest amount of time?
How did you solve the problem? What is your algorithm?
Answer:
10 weeks
Explanation:
100 blocks stacked over 10 weeks will be 1000 meters tall
1000 divided by 100 equals 10
The shortest amount of time it will take to build the tower is 10 weeks.
How can the tower be built in the shortest amount of time?To minimize the construction time, Tony Stark can follow a strategy where he first builds 10 stacks of 100 blocks each, which will take 10 weeks.
Then, he can stack these 10 stacks on top of each other in a single week since they are all 100 blocks or less. By doing so, he can complete the tower in a total of 10 weeks.
Read more about tower construction
brainly.com/question/30730573
#SPJ2
For this lab you will do 2 things:
Solve the problem in an algorithm
Code it in Python
Problem:
Cookie Calories
A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 "servings" in the bag and that a serving equals 300 calories. Write a program that asks the user to input how many cookies he or she ate and the reports how many total calories were consumed.
*You MUST use constants to represent the number of cookies in the bag, number of servings, and number of calories per serving. Remember to put constants in all caps!
Make sure to declare and initialize all variables before using them!
Then you can do the math using those constants to find the number of calories in each cookie.
Make this program your own by personalizing the introduction and output.
Sample Output:
WELCOME TO THE CALORIE COUNTER!!
Answer:
Here is the Python program:
COOKIES_PER_BAG = 40 #sets constant value for bag of cookies
SERVINGS_PER_BAG = 10 #sets constant value for serving in bag
CALORIES_PER_SERVING = 300 #sets constant value servings per bag
cookies = int(input("How many cookies did you eat? ")) #prompts user to input how many cookies he or she ate
totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG)); #computes total calories consumed by user
print("Total calories consumed:",totalCalories) #displays the computed value of totalCalories consumed
Explanation:
The algorithm is:
StartDeclare constants COOKIES_PER_BAG, SERVINGS_PER_BAG and CALORIES_PER_SERVINGSet COOKIES_PER_BAG to 40Set SERVINGS_PER_BAG to 10Set CALORIES_PER_SERVING to 300Input cookiesCalculate totalCalories: totalCalories ← cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG))Display totalCaloriesI will explain the program with an example:
Lets say user enters 5 as cookies he or she ate so
cookies = 5
Now total calories are computed as:
totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG));
This becomes:
totalCalories = 5 * (300/40/10)
totalCalories = 5 * (300/4)
totalCalories = 5 * 75
totalCalories = 375
The screenshot of program along with its output is attached.
When a variable is stored in memory, it is associated with an address. To obtain the address of a variable, the & operator can be used. For example, &a gets the memory address of variable a. Let's try some examples. Write a C program addressOfScalar.c by inserting the code below in the main function
Solution :
#include<stdio.h>
int main()
{
char charvar='\0';
printf("address of charvar = %p\n",(void*)(&charvar));
printf("address of charvar -1 = %p\n",(void*)(&charvar-1));
printf("address of charvar +1 = %p\n",(void*)(&charvar+1));
int intvar=1;
printf("address of intvar = %p\n",(void*)(&intvar));
printf("address of intvar -1 = %p\n",(void*)(&intvar-1));
printf("address of intvar +1 = %p\n",(void*)(&intvar+1));
}
To write a letter using Word Online, which document layout should you choose? ASAP PLZ!
Traditional... See image below
Answer: new blank document
Explanation: trust is key
Match the term to its use in creating perspective.
1. placement
2. size
3. color
4. converging lines
A. Lines merging into a distance create
an illusion of depth.
B. The position of a shape relative to the
horizon affects your perception of depth.
C. Adds spatial depth to a shape.
D. A smaller shape, placed appropriately,
appears more distant than a similar
larger shape.
Answer:
1. POSITION - The position of a shape relative to the
horizon affects your perception of depth.
2. CONVERGING LINES- Lines merging into a distance create
an illusion of depth.
3.COLOR- Adds spatial depth to a shape.
4. SIZE - A smaller shape, placed appropriately,
appears more distant than a similar
larger shape.
took test on PLATO. 100%
Ms. Myers commented that _____ she slept in at the hotel was better than _____ she slept in at home.