Lab 5B –Value Returning Functions

Falling Distance
When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period:

d = ½ gt2

The variables in the formula are as follows:
d is the distance in meters
g is 9.8 (the gravitational constant)
t is the amount of time in seconds the object has been falling

Your program will calculate the distance in meters based on the object’s falling distance.

Modularity: Your program should contain 2 functions:
main – will call the falling_distance function in a loop, passing it the values 1 – 10 as arguments (seconds the object has been falling). It will display the returned distance.
falling_distance – will be passed one parameter which is the time in seconds the object has been falling and will calculate and return the distance in meters. falling_distance should be stored in a separate file (module) called distance.py You will import distance before your main function in your original program file.
Input Validation: None needed
Output: Should look like this:
Time Falling Distance
-----------------------------
1 4.90
2 19.60
3 44.10
4 78.40
5 122.50
6 176.40
7 240.10
8 313.60
9 396.90
10 490.00
Programming Style Requirements.
• Comments – Begin your program with a comment that includes: a) your name, b)program status – either “Complete” or describe any incomplete or non-functioning part of your program c)A 1-3 line description of what the program does.
• Function comments – each function should begin with a comment explaining what the function does
• Variable names – use meaningful variable names such as total_taxes or num_cookies.
• Function names – use meaningful verb names for functions such as display_taxes.
• Named constants – Use named constants for all number values that will not be changed in the program such as RECIPE_SUGAR = 1.5. See section 2.9 on Named Constants
Your program file: yourlastname_Lab5B.py
Your distance module: distance.py

Answers

Answer 1

Code (short for source code) describes text written using a programming language by a computer programmer.

What is code?

Code (short for source code) describes text written using a programming language by a computer programmer. Examples of programming languages include C, C#, C++, Java, Perl, and PHP.

Code is also be used less formally to refer to text written for markup or styling languages, like HTML and CSS (Cascading Style Sheets). For example, you may see people refer to code in numerous languages, such as "C code," "PHP code," "HTML code," or "CSS code."

Please create the files as shown in the screenshot

Here is the complete code in python,

# distance.py file

def falling_distance(time):

   GRAVITY=9.8

   return GRAVITY*time**2/2

# position.py file

from distance import falling_distance

def main():

   print('{0:<10}{1:<20}'.format('Time','Falling Distance'))

   print('-'*26)

   for i in range(1,11,1):

       print('{0:<10}{1:<20.2f}'.format(i,falling_distance(i)))

main()

Learn more about Code

https://brainly.com/question/17204194

#SPJ1

Lab 5B Value Returning FunctionsFalling DistanceWhen An Object Is Falling Because Of Gravity, The Following
Lab 5B Value Returning FunctionsFalling DistanceWhen An Object Is Falling Because Of Gravity, The Following

Related Questions

Adding multiple events in an array of elements using 'querySelectorALL' in JavaScript?
In my HTML, i already have three Divs.

In my script section, this is my code:
for (var i = 0; i < box.length; i++) {
box[i].addEventListener("mouseover", function () {
box.style.backgroundColor = "blue";
});
}
box.addEventListener("mouseout", function () {
box[i].style.backgroundColor = "pink";
});

Ok so based on that code snippet, am trying to add a mouseover and mouseout events in each element so that when I hover on and off each div they change color. But it doesn't seem to work. Any advice on how I can make this work?

Answers

It looks like there are a couple of issues with your code. Here are some suggestions on how to fix them:

Use querySelectorAll to select all the div elements:

javascript

var box = document.querySelectorAll("div");

In your loop, you need to refer to the current element using this:

javascript

for (var i = 0; i < box.length; i++) {

 box[i].addEventListener("mouseover", function () {

   this.style.backgroundColor = "blue";

 });

 box[i].addEventListener("mouseout", function () {

   this.style.backgroundColor = "pink";

 });

}

In the mouseover and mouseout event listeners, you need to refer to the current element using this. Also, you need to set the backgroundColor property of the current element (this), not the box variable.

Putting it all together, your updated code should look like this:

javascript

var box = document.querySelectorAll("div");

for (var i = 0; i < box.length; i++) {

 box[i].addEventListener("mouseover", function () {

   this.style.backgroundColor = "blue";

 });

 box[i].addEventListener("mouseout", function () {

   this.style.backgroundColor = "pink";

 });

}

With these changes, you should be able to hover over and off each div to change its background color.

Answer:

The issue with your code is that you are trying to set the background color of the entire box element when you should only be changing the background color of the current element that is being hovered over or moused out.

To fix this, you can modify your code to use the this keyword inside the event listener function to refer to the current element that is being hovered over or moused out. Here's the updated code:

// Get all the box elements

var box = document.querySelectorAll(".box");

// Loop through each box element and add mouseover and mouseout event listeners

for (var i = 0; i < box.length; i++) {

 box[i].addEventListener("mouseover", function () {

   this.style.backgroundColor = "blue";

 });

 box[i].addEventListener("mouseout", function () {

   this.style.backgroundColor = "pink";

 });

}

In this updated code, we are using the this keyword to refer to the current element that is being hovered over or moused out. We are also setting the background color of the current element using the style.backgroundColor property, which ensures that only the current element's background color is changed.

Note: Make sure that your HTML elements have the class box in order for the querySelectorAll method to select them correctly.

For Questions 3-5, consider the following code:


stuff = []





stuff.append(1.0)


stuff.append(2.0)


stuff.append(3.0)


stuff.append(4.0)


stuff.append(5.0)





print(stuff)



3. What data type are the elements in stuff?


4. What is the output for print(len(stuff))?


5. What is the output for print(stuff[0])?

Answers

Answer:
The .append() function adds the inserted value to a list. You are passing in floats.

In this case, you appended 5 things to the list, so the list looks like:
stuff = [1.0, 2.0, 3.0, 4.0, 5.0]

And, when you run print(stuff) you will end up with that list. However, when you run print(len(stuff)) you are counting the length of the list. You have 5 things in the list, so the output will be 5.

When you wish to specify a position in a list to print, that's when stuff[] comes in. Essentially, by running print(stuff[0]) you are specifying that you only want the first item in the list. This would output 1.0

You can always try this by putting this into an IDE, and running it.

A software developer is using a microphone and a sound editing app to
collect and edit sounds for his new game.
When collecting sounds, the software developer can decide on the sampling
resolution he wishes to use.

ii) Describe how sampling resolution will affect how accurate the
stored digitised sound will be.
b) The software developer will include images in his new game.
i
ii) The software developer is using 16-colour bit-map images.
State the number of bits required to encode data for one pixel of his
image.
iii) One of the images is 16384 pixels wide and 512 pixels high.
The developer decides to save it as a 256-colour bit-map image.
Calculate the size of the image file in gibibytes.

Answers

Answer:

ii) Sampling resolution is the number of bits used to represent each sample of the analog sound wave. Higher sampling resolution means that each sample can be represented with more bits, which results in a more accurate representation of the original sound. This is because higher resolution provides more levels of amplitude that can be represented, resulting in a more faithful reproduction of the original sound wave.

b)

i) The number of bits required to encode data for one pixel of a 16-color bitmap image is 4 bits.

ii) The size of the image file can be calculated as follows:

Number of pixels in the image = 16384 x 512 = 8388608

Number of bits required to encode one pixel in a 256-color bitmap image = 8 bits

Total number of bits required to encode the image = 8388608 x 8 = 67108864 bits

Convert bits to gibibytes:

1 gibibyte = 2^30 bytes

1 byte = 8 bits

Therefore,

67108864 bits = 8388608 bytes = 8.192 megabytes (MB)

1 MB = 2^20 bytes = 0.0009765625 gibibytes

Therefore,

8.192 MB = 0.0078125 gibibytes

Hence, the size of the image file is approximately 0.0078125 gibibytes.

Assume that you have been assigned the task to create an object-oriented system that could be used to support students in finding an appropriate apartment to live in next semester. What are the different types of objects (i.e., classes) you would want to include in your system? Draw an inheritance hierarchy.

Answers

Here are some possible classes that could be included in an object-oriented system to support students in finding an appropriate apartment:

Student

Apartment

Landlord

SearchEngine

ApartmentListing

FavoriteList

Lease

Here is a possible inheritance hierarchy for these classes:

           +-----------+

           |   Person  |

           +-----------+

                 |

           +-----------+

           |  Student  |

           +-----------+

                 |

           +-----------+

           | Apartment |

           +-----------+

           /         \

  +-----------+   +-----------+

  |  Landlord |   | ApartmentListing |

  +-----------+   +-----------+

                           |

                   +-------------+

                   |  Lease      |

                   +-------------+

What is object oriented system?

An object-oriented system is a type of software system that is based on the principles of object-oriented programming (OOP). OOP is a programming paradigm that focuses on the use of objects, which are instances of classes, to represent and manipulate data.

In an object-oriented system, software applications are built using objects that interact with each other to perform specific tasks. Each object has a set of attributes (data) and methods (functions) that define its behavior. The objects in the system communicate with each other by sending messages, which trigger the execution of methods on other objects.

To know more about object oriented system, visit:

https://brainly.com/question/29024678

#SPJ1

The answer of the given question based on the  to create an object-oriented system that could be used to support students in finding an appropriate apartment is given below,

What is Hierarchy?

Hierarchy refers to a system of organizing things or people into different levels of importance or authority. It involves grouping entities based on their characteristics or relationships to each other, and arranging them in a structured manner, from the most important or broadest category to the least important or most specific category.

we can create an object-oriented system that includes the following classes:

Apartment: This class represents an apartment with attributes such as the number of bedrooms, the rent amount, the location, and the amenities.Student: This class represents a student with attributes such as name, age, major, and budget for rent.ApartmentSearch: This class represents the process of searching for an apartment. It will have methods to search for apartments based on the student's preferences such as location, budget, and amenities.RentalAgreement: This class represents the agreement between the student and the apartment owner. It will have attributes such as the rental period, the monthly rent, and the security deposit.

Here's the inheritance hierarchy for the above classes:

                +--------------+

               |   Apartment  |

               +--------------+

                      / \

                     /   \

                    /     \

                   /       \

                  /         \

   +-------------+           +-------------+

   |   Student   |           | ApartmentSearch |

   +-------------+           +----------------+

                              /

                             /

                            /

                           /

                          /

             +----------------------+

             |    RentalAgreement    |

             +----------------------+

In this hierarchy, ApartmentSearch inherits from Apartment as it uses the apartment attributes for searching. RentalAgreement inherits from Apartment and Student as it involves both the apartment and the student in the rental process.

To know more about Entity visit:

https://brainly.com/question/28234733

#SPJ1

Nested for loops. C++
Integer userValue is read from input. For each number from 1 to userValue, output the number indented by the number's value of dash characters, '-'. End each output with a newline.

Ex: If the input is 5, then the output is:
-1
--2
---3
----4
-----5
------------------------
#include
using namespace std;

int main() {
int userValue;
int i;
int j;

cin >> userValue;

/* Your code goes here */

return 0;
}

Answers

Answer:

Here's the code that solves the problem using nested for loops in C++:

Read userValue from input

for i = 1 to userValue

   // print i with i number of dashes

   for j = 1 to i

       print "-"

   end for

   print i and a newline character

end for

Explanation:

Explanation:

We first read the user input userValue from input.

We use a for loop to iterate from 1 to userValue.

Inside the loop, we use another for loop to print the required number of dashes before the number. The number of dashes is equal to the current value of i.

We print the number i after the dashes, and end the line with a newline character.

After the loop ends, the program terminates.

Note: This is a general pseudocode that can be implemented in any programming language. The actual implementation may vary depending on the programming language used.

1.Is a data storage device 2.Hard copy information into soft copy information 3.Make paper copy of a document 4.Any annoying or disturbing sound 5.Convert digital to Analog signal 6.Combining multiple pieces of data 7.Produces a paper copy of the information displayed on the monitor 8.USB Drive 9.List detail or summary data or computed information 10.Accurate B Photocopier A. B. Noise C. Hard disk D. Scanner E. Modem F. Aggregation G. Printer H. Small storage 1. Report J. Free from Erre​

Answers

The following which is mostly about technology are matched accordingly:

H. Small storage - USB Drive

D. Scanner - Hard copy information into soft copy information

A. Photocopier - Make paper copy of a document

B. Noise - Any annoying or disturbing sound

E. Modem - Convert digital to Analog signal

F. Aggregation - Combining multiple pieces of data

G. Printer - Produces a paper copy of the information displayed on the monitor

C. Hard disk - a data storage device

Report - List detail or summary data or computed information

J. Free from Error - Accurate

How do the above technology help to improve productivity?

The above technologies (except for noise which comes as a result of the use of the above) help to improve effectiveness in various ways.

They enhance productivity, streamline processes, enable faster communication and access to information, facilitate data analysis and decision-making, and provide efficient data storage and retrieval, ultimately leading to improved performance and outcomes.

Learn more about technology  at:

https://brainly.com/question/9171028

#SPJ1

Full Question:

Part II. Matching (10pt) "A" on the taskbar 1.Is a data storage device 2.Hard copy information into soft copy information 3.Make paper copy of a document 4.Any annoying or disturbing sound 5.Convert digital to Analog signal 6.Combining multiple pieces of data 7.Produces a paper copy of the information displayed on the monitor 8.USB Drive 9.List detail or summary data or computed information 10.Accurate A. Photocopier B. Noise C. Hard disk D. Scanner E. Modem F. Aggregation G. Printer H. Small storage 1. Report J. Free from Error​

Como se hace hoja en word incluyendo sobre de correspondencia ?​

Answers

Answer:

Step 1: Set up your mailing list

* If you don’t have a mailing list, you can create one during mail merge. Collect all of your address lists, and add them to your data source

Step 2: Test your Envelope layout

* Go to File > New > Blank document.

Go to Mailings > Envelopes.

Print envelopes

In the Delivery address box, type a sample address to test how an envelope looks when printed.

Type your address in the Return address box.

Return address box

Select Options > Envelope Options and do the following:

Choose the size that matches your envelope or choose Custom size to set size.

Envelope options tab for setting envelope size and address fonts

If needed, choose a font and the left and top offset position for the Delivery address and Return address.

On the Printing Options tab, confirm the correct Feed method is selected, load the envelope to match the illustration, and then choose OK.

Feed options diagram for feeding envelopes into the printer

Choose Print, and then choose Yes to save the return address as the default address.

Step 3: Start the mail merge

Go to Mailings > Start Mail Merge > Envelopes.

Start Mail Merge menu

In the Envelope Options dialog box, check your options and then choose OK.

If you'd like to add a return address, or logo, to your envelope now is a good time to add that.

Choose File > Save.

Step 4: Link your mailing list to your main document

Go to Mailings > Select Recipients.

Type a New List command

Choose a data source. For more info, see Data sources you can use for a mail merge.

Choose File > Save.

Step 5: Add the address block to the envelope

The address block is a mail merge field that you place where you want addresses to appear on the envelope. To better see where press CTRL+SHIFT+8 to turn on paragraph marks (¶).

Place your cursor where you want the address block to go.

Go to Mailings > Address Block and choose a format. For more info, see Insert Address Block.

Address block options

Choose a format in the Insert Address Block dialog box, for the recipient's name as it will appear on the envelope.

If you want, choose the Next record button for mail merge preview results or Previous Previous record button for mail merge preview results to move through a few records in your data source to see how they look.

Choose OK.

Go to File > Save to save your merge document.

Step 6: Preview and Print the envelopes

Accept the Next record button for mail merge preview results or the Previous record button for mail merge preview results to move through a few records in your data source to see how they look.

Choose Finish & Merge > Print Documents.

Step 7: Save your mail merge envelope document

When you save the mail merge envelope document, it stays connected to your mailing list for future use.

To reuse your envelope mail merge document, open the document and choose Yes when Word prompts you to keep the connection. To change addresses in the envelope mail merge document, open the document and accept  Edit Recipient List to sort, filter, and choose specific addresses.

Which situation is enabler for the rise of Artificial Intelligence in recent years

Answers

Answer:

The development of artificial intelligence has been enabled by advances in computing technology, which has allowed for the creation of more sophisticated algorithms and software.

Which case would benefit from Explainable Artificial principles?

Answers

Answer:

The doctor who tends to rely on AI-based systems in order to make the diagnosis is the specific case that might be benefited from the explainable principle of artificial intelligence.

Explanation:

Why is it necessary to use a flowchart

Answers

Answer:

When designing and planning a process, flowcharts can help you identify its essential steps and simultaneously offer the bigger picture of the process. It organises the tasks in chronological order and identify them by type, e.g. process, decision, data, etc.

(c++)Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. Write a program to help them analyze their data. a function to read and store the runners’ names and the numbers of miles run each day;

 a function to find the total miles run by each runner and the average number of miles run each

day;

 a function to output the results.

The output must be in the form of a table where the columns contain

 The runner’s name..... USING STRUCTS rather than arrays.



Here is the file "runners.txt"

Johnson 05 11 12 41 10 10 17

Samantha 20 12 32 04 06 32 24

Ravi 11 22 33 43 55 10 26

Sheila 10 02 03 40 60 20 15

Ankit 09 20 20 10 55 65 81

Answers

Answer:

#include <iostream>

#include <fstream>

#include <string>

#include <iomanip>

using namespace std;

const int NUM_RUNNERS = 5;

const int NUM_DAYS = 7;

struct Runner {

   string name;

   int miles[NUM_DAYS];

   int totalMiles;

   float averageMiles;

};

void readData(Runner runners[]) {

   ifstream inputFile("runners.txt");

   if (!inputFile.is_open()) {

       cout << "Error: could not open file\n";

       return;

   }

   for (int i = 0; i < NUM_RUNNERS; i++) {

       inputFile >> runners[i].name;

       for (int j = 0; j < NUM_DAYS; j++) {

           inputFile >> runners[i].miles[j];

       }

   }

   inputFile.close();

}

void calculateTotals(Runner runners[]) {

   for (int i = 0; i < NUM_RUNNERS; i++) {

       int total = 0;

       for (int j = 0; j < NUM_DAYS; j++) {

           total += runners[i].miles[j];

       }

       runners[i].totalMiles = total;

       runners[i].averageMiles = static_cast<float>(total) / NUM_DAYS;

   }

}

void outputResults(Runner runners[]) {

   cout << setw(12) << left << "Runner";

   cout << setw(12) << right << "Total Miles";

   cout << setw(12) << right << "Average Miles" << endl;

   for (int i = 0; i < NUM_RUNNERS; i++) {

       cout << setw(12) << left << runners[i].name;

       cout << setw(12) << right << runners[i].totalMiles;

       cout << setw(12) << right << fixed << setprecision(2) << runners[i].averageMiles << endl;

   }

}

int main() {

   Runner runners[NUM_RUNNERS];

   readData(runners);

   calculateTotals(runners);

   outputResults(runners);

   return 0;

}

Explanation:

This program reads the data from the "runners.txt" file and stores it in an array of structs, where each struct represents a runner and contains the runner's name, the number of miles run each day, and the total and average number of miles run. The program then calculates and outputs the total and average miles run by each runner in a table format.

Which situations are better suited to an indefinite (while) loop? Select 3 options.

A. writing a program that will average 20 numbers
B. writing a program to average the temperatures for the last 30 days
C. having the user guess a number and keep guessing till they get it right
D. allowing the user to enter their best friends names without saying how many friends they can have
E. writing a program to average numbers without requiring the user to count the numbers

Answers

Answer:

C. having the user guess a number and keep guessing till they get it right

D. allowing the user to enter their best friends names without saying how many friends they can have

E. writing a program to average numbers without requiring the user to count the numbers

Explanation:

Indefinite (while) loops are useful when we don't know exactly how many iterations will be needed, or when the user should be able to keep performing an action until a certain condition is met. In the situations described in options B, C, and D, we don't know exactly how many times the loop will need to execute, so an indefinite loop would be appropriate. In option A, we know that we will need to average exactly 20 numbers, so a definite (for) loop with 20 iterations would be more appropriate.

Consider the following code and answer the question below.

Answers

FOR X = 1 TO 10 FOR Y = 10-X IF A(Y)<A(Y+1) THEN SWAP A(Y),A(Y+1) END IF NEXT Y NEXT X FOR J = 1 TO 10 PRINTA(J); NEXTJ END​

1

11

111

1111

11111

What will be the calculation?

As Given in the question:

The above QBasic code

Required,

The output

The iteration on the third line is repeated 5 times; i.e. for values of j from 1 to 5. In each iteration, the value of N is printed and the next value is calculated.

Initially, the value of N is 1 ---- on line 2

So, 1 is printed first. The next value of N is as follows:We keep replacing N (on the right-hand side) with current N value.

Therefore, The program is given below, 100 If, Load / by Load the first value 101 Subt Y / Subtract the value of Y, store result in AC.

Learn more about program on:

brainly.com/question/11023419

#SPJ1

A Chief Executive Officer (CEO) is dissatisfied with the level of service from the company's new service provider. The service provider is preventing the CEO from sending email from a work account to a personal account.
Which of the following types of service providers is being used?
A. Telecommunications service provider
B. Cloud service provider
C. Master managed service provider
D. Managed security service provider

Answers

Answer:

D

Because the security man is protecting the company

10.2. Is the variance favorable or unfavorable? TRUE FALSE items TRUE 1. Goods in transit & goods on consignment are the same, 2. Gross profit is the difference between net sales & cost of goods sold. 3. Purchase records end up with paying the voucher. 4. Payment for janitors & clerks is calculated under direct labor. TRUE 5. Variance is the deviation between actual cost & standard cost.​

Answers

Answer:

The statement "Variance is the deviation between actual cost & standard cost" is true.

The statement "Goods in transit & goods on consignment are the same" is false.

The statement "Gross profit is the difference between net sales & cost of goods sold" is true.

The statement "Purchase records end up with paying the voucher" is true, as purchase records are used to create invoices and payment vouchers.

The statement "Payment for janitors & clerks is calculated under direct labor" is false, as payment for janitors and clerks is typically categorized under indirect labor.

Therefore, there are 3 true statements and 2 false statements.

Explanation:

Select the correct answer from each drop-down menu.

Maria is preparing a slide show on procedural programming. She wants to define procedural programming in one of the slides. Help Maria complete
the definition.

Procedural-oriented programming is a programming paradigm that views a problem as a series of ____ to be performed in a _____ manner.

a series of (objects, tasks, statements)

to be preformed in a (sequential, random, logical)

Answers

Answer:

Procedural-oriented programming is a programming paradigm that views a problem as a series of tasks to be performed in a sequential manner. In procedural programming, a program is broken down into a series of steps or procedures that are executed in a particular order to achieve a desired outcome. Each procedure is designed to perform a specific task, and the program flows from one procedure to the next until the final task is completed. This approach to programming is often used for creating small to medium-sized programs and is known for its simplicity, modularity, and ease of debugging.

Explanation:

Describe the difference between transactional and analytical information and determine how
robots could affect each for a grocery store such as Safeway.

Answers

Answer:

Transactional information refers to the real-time data related to the day-to-day operations of a business, such as sales transactions, inventory levels, and customer orders. Analytical information, on the other hand, is derived from transactional data and is used to gain insights and make strategic decisions.

In the case of a grocery store like Safeway, robots could have a significant impact on both types of information. For transactional information, robots could be used to automate tasks such as restocking shelves, cleaning, and even operating cash registers, providing real-time data on inventory levels and sales transactions.

For analytical information, robots could be used to gather and analyze data on customer behavior, such as purchasing patterns and preferences, as well as data on product performance and supply chain efficiency. This information could be used to optimize pricing strategies, improve product offerings, and streamline supply chain operations.

Overall, robots have the potential to greatly enhance the transactional and analytical information available to grocery stores like Safeway, enabling them to make data-driven decisions and improve operational efficiency.

Explanation:

Write a program that uses the following initializer list to find if a random value entered by a user is part of that list.

v = [54, 80, 64, 90, 27, 88, 48, 66, 30, 11, 55, 45]

The program should ask the user to enter a value. If the value is in the list, the program should print a message that contains the index. If it is not in the list, the program should print a message containing -1.

Hint: The values in the list are integers, so you should also get the value from the user as an integer. We can assume the user will only enter integer values.

Sample Run
Search for: 64
64 was found at index 2

Answers

Answer:

Here's a Python program that accomplishes the task:

v = [54, 80, 64, 90, 27, 88, 48, 66, 30, 11, 55, 45]

# Get user input

search_value = int(input("Search for: "))

# Search for value in list and print result

if search_value in v:

   print(search_value, "was found at index", v.index(search_value))

else:

   print("-1")

Explanation:

Here's a sample output for when the user searches for the value 64:

Search for: 64

64 was found at index 2

A vending machine serves chips, fruit, nuts, juice, water, and coffee. The machine owner wants a daily report indicating what items sold that day. Given boolean values (1 or 0) indicating whether or not at least one of each item was sold (in the order chips, fruit, nuts, juice, water, and coffee), output a list for the owner. If all three snacks were sold, output "All-snacks" instead of individual snacks. Likewise, output "All-drinks" if appropriate. For coding simplicity, output a space after every item, including the last item.

Ex: If the input is:

Answers

Here's an example solution in Python to generate the desired report:

scss

# Initialize empty lists to store sales data

chips_sold = []

fruit_sold = []

nuts_sold = []

juice_sold = []

water_sold = []

coffee_sold = []

# Loop through sales data

for day in range(3):

   # Ask user for input indicating which items were sold that day

   print("Day", day+1, "sales:")

   chips_sold.append(int(input("Chips sold (1=Yes, 0=No): ")))

   fruit_sold.append(int(input("Fruit sold (1=Yes, 0=No): ")))

   nuts_sold.append(int(input("Nuts sold (1=Yes, 0=No): ")))

   juice_sold.append(int(input("Juice sold (1=Yes, 0=No): ")))

   water_sold.append(int(input("Water sold (1=Yes, 0=No): ")))

   coffee_sold.append(int(input("Coffee sold (1=Yes, 0=No): ")))

# Generate report

report = ""

if all(chips_sold):

   report += "All-snacks "

else:

   if chips_sold[0]:

       report += "Chips "

   if chips_sold[1]:

       report += "Chips "

   if chips_sold[2]:

       report += "Chips "

if all([juice_sold[i] or water_sold[i] for i in range(3)]):

   report += "All-drinks "

else:

   if juice_sold[0] or water_sold[0]:

       report += "Juice Water "

   if juice_sold[1] or water_sold[1]:

       report += "Juice Water "

   if juice_sold[2] or water_sold[2]:

       report += "Juice Water "

if all(nuts_sold) and all(fruit_sold):

   report += "All-snacks "

else:

   if nuts_sold[0] and fruit_sold[0]:

       report += "Nuts Fruit "

   if nuts_sold[1] and fruit_sold[1]:

       report += "Nuts Fruit "

   if nuts_sold[2] and fruit_sold[2]:

       report += "Nuts Fruit "

if coffee_sold[0]:

   report += "Coffee "

if coffee_sold[1]:

   report += "Coffee "

if coffee_sold[2]:

   report += "Coffee "

# Print report

print(report)

What is the vending machine about?

This code first initializes empty lists to store sales data for each item. Then, it loops through each day of sales, asking the user for input indicating which items were sold that day.

Therefore, After collecting the sales data, the code generates the report by checking which items were sold each day and concatenating the appropriate string to the report variable. If all three snacks were sold, it appends "All-snacks" instead of individual snacks. Likewise, if both juice and water were sold on a particular day, it appends "All-drinks" instead of the individual items. Finally, it outputs the report.

Learn more about vending machine from

https://brainly.com/question/6471187

#SPJ1

2. The Internet allows you to communicate with someone from
O A. any location.
B. other citizens that speak the same language as you.
O C. remote rural areas of the southwestern United States.
O D. wealthy families.

Answers

It’s any location as long as they have internet

Answer:

A

Explanation:

The internet is broad and even has translation systems which will allow it to work for people of different languages and it available to all part of the world

quick code question:)

Answers

Answer:

The value of x[3] would be "c".

Explanation:

Here is a breakdown of the code:

The variable x is initialized as an array with three elements: "a", "b", and "c".

The insertItem function is called with three arguments: the array x, the index 2, and the string "f". This function inserts the string "f" at index 2 of the array x, shifting all other elements to the right.

The modified array x is printed to the console using console.log.

Since "c" was originally at index 2 of the array and the insertItem function inserted "f" at that index, "c" is now at index 3 of the modified array. Thus, x[3] is equal to "c".

functions with loops C++
Define the function PrintValues() that takes two integer parameters and outputs all integers starting with the first and ending with the second parameter, each multiplied by 1000 and followed by a newline. The function does not return any value.
Ex: If the input is 2 6, then the output is:
2000
3000
4000
5000
6000
Note: Assume the first integer parameter is less than the second.
------------------------------------
#include
using namespace std;

/* Your code goes here */

int main() {
int numberA;
int numberB;

cin >> numberA;
cin >> numberB;
PrintValues(numberA, numberB);

return 0;
}

Answers

Answer:

Here's the pseudocode for the PrintValues() function:

function PrintValues(numberA, numberB)

   for i = numberA to numberB

       print i * 1000

       print newline

   end for

end function

Explanation:

This function takes two integer parameters numberA and numberB. It then loops through all integers between numberA and numberB, inclusive. For each integer, it multiplies it by 1000 and prints the result, followed by a newline.

How can i write void function that takes three arguments by reference. Your function should modify the values in the arguments so that the first argument contains the largest value, the second the second-largest, and the third the smallest value?​

Answers

Answer:

void sort_three_numbers(int& num1, int& num2, int& num3) {

   if (num1 < num2) {

       std::swap(num1, num2);

   }

   if (num2 < num3) {

       std::swap(num2, num3);

   }

   if (num1 < num2) {

       std::swap(num1, num2);

   }

}

Explanation:

In this implementation, we first compare num1 and num2, and swap them if num1 is smaller than num2. Then we compare num2 and num3, and swap them if num2 is smaller than num3. Finally, we compare num1 and num2 again, and swap them if num1 is smaller than num2. After these comparisons and swaps, the values of the arguments will be modified so that num1 contains the largest value, num2 contains the second-largest value, and num3 contains the smallest value.

To use this function, you can call it with three integer variables:

int num1 = 10;

int num2 = 5;

int num3 = 3;

sort_three_numbers(num1, num2, num3);

std::cout << num1 << " " << num2 << " " << num3 << std::endl; // prints "10 5 3"

A mid-sized graphic design company has a position for a graphic design artist. The hiring panel has narrowed the candidates down to three.

Candidate A is a recent college graduate. He has a degree in digital design and experience using Adobe’s photo design software. Candidate A has strong opinions about his design process and argued with the interview panel at length about their critique of his portfolio.

Candidate B has just completed an internship at a large graphic design corporation. She has experience using some of the latest design software, but her work has always been in collaboration with others. She has never completed a design job on her own.

Candidate C has worked in corporate advertising for the past ten years. She has experience in design, but her methods of production are more traditional. She does not have experience with the latest design software, nor is she very interested in learning it.

Which candidate would most likely be hired for this position?

Responses

candidate A
candidate A

candidate C
candidate C

candidate B
candidate B

None




--for education--

Answers

General instructions on how the hiring panel should proceed to reach its judgement. Here are some actions they might consider: Examine the portfolios of contenders, Interview candidates and decide.

Which of the following best sums up the advantages and disadvantages of digital publishing?

Digital publication makes it possible to produce and share content more quickly and effectively, but it also creates new opportunities for problems with piracy, copyright, and plagiarism.

One of the most important talents a news anchor needs to cultivate is which of the following?

TV news anchors need strong public speaking abilities to enable them to confidently conduct interviews and present daily news items. Also, they employ these abilities to keep conversing easily with their audience despite problems.

To know more about copyright visit:-

https://brainly.com/question/29506018

#SPJ1


Which strategy helps job seekers organize and track their job search progress efficiently?

Answers

A job seeker who is using an online resources for the job search shows that how technology as well as the internet in the particular has been helped to simplify our everyday life.

What is the use of online resources in finding a job?

The use of the online resources in the job search provides a much faster way of reaching and covering a wide range of available jobs within and far beyond your immediate geographical range.

Before the internet, the job searches were typically done manually, and the process has been consumed a lot of time and the resources and was mostly limited a certain geographical range.

Therefore, nowadays, someone in the US can easily apply for a job post on the internet all the way in Germany.

Learn more about internet on:

https://brainly.com/question/13308791

#SPJ9

what project can i do as a first year student for my computer diagnosis class? can i have 3 easy options that would be possible for me who doesn’t know how to code to accomplish this project? ​

Answers

Answer:Sure, here are three project ideas that could be suitable for a first-year computer diagnosis class, and don't require much coding:

Create a step-by-step guide for diagnosing and fixing common computer issues: You can research and create a document that outlines the most common computer problems (e.g., slow performance, virus/malware infections, hardware failures), and the steps one can take to diagnose and fix them. This project could involve researching online resources, compiling information into an organized format, and creating visuals to accompany the text.

Perform a diagnostic test on a computer and report your findings: You can obtain an old or unused computer and run a diagnostic test on it using readily available software tools like CrystalDiskInfo or Speccy. After running the test, you can write a report that describes the computer's hardware and software configurations, identifies any problems or errors found, and recommends potential solutions or repairs.

Create a troubleshooting flowchart for a specific software application: You can choose a software application that you are familiar with and create a flowchart that outlines the steps to troubleshoot any issues that may arise while using it. This project could involve researching common problems associated with the application, organizing the steps into a logical sequence, and creating a visual representation of the flowchart.

Remember to always consult with your professor for approval and guidance on your project ideas. Good luck!

Explanation:

**ANSWER MUST BE IN PSEUDOCODE**

Write a program that will accept an unknown number of grades in the form of numbers, calculates the GPA, and then outputs the letter grade for each with the calculated GPA.

For the input, the first number will reflect the number of grades being entered. The remaining inputs will be the actual grades in number form. Only grade values from zero to four will be accepted. Any other entered value should receive a zero as the value inserted into the array. The input and output will use the following numbers to reflect a letter grade:

A = 4
B = 3
C = 2
D = 1
F = 0
To calculate the GPA, total up the values in the grades array and divide by the number of elements in the array.

Testing Invalid Number of Grades
If the user enters a value of zero or less for the number of grades being entered, the following should output:

Example Input

-4 1 2 3 4
Example Output

The number of grades to enter must be greater than 0.
Testing Valid Grades
Example Input

4 4 3 2 1
Example Output

The following grades: A B C D
Earned a GPA of: 2.5
Testing Valid and Invalid Grades
Example Input

4 4 6 2 -1
Example Output

The following grades: A F C F
Earned a GPA of: 1.5

**ANSWER MUST BE IN PSEUDOCODE**

Answers

Answer:

SET totalGrades to 0

SET totalPoints to 0

SET numGrades to INPUT from user

SET grades[numGrades] to empty array

IF numGrades <= 0 THEN

OUTPUT "The number of grades to enter must be greater than 0."

ELSE

FOR i from 0 to numGrades-1 DO

SET grade to INPUT from user

IF grade < 0 OR grade > 4 THEN

SET grade to 0

END IF

SET grades[i] to grade

SET totalPoints to totalPoints + grade

END FOR

Explanation:

FOR i from 0 to numGrades-1 DO

   SET letterGrade to empty string

   IF grades[i] == 4 THEN

       SET letterGrade to "A"

   ELSE IF grades[i] == 3 THEN

       SET letterGrade to "B"

   ELSE IF grades[i] == 2 THEN

       SET letterGrade to "C"

   ELSE IF grades[i] == 1 THEN

       SET letterGrade to "D"

   ELSE

       SET letterGrade to "F"

   END IF

   OUTPUT "The following grades: " + letterGrade + " "

END FOR

SET gpa to totalPoints / numGrades

OUTPUT "Earned a GPA of: " + gpa

END IF

You guys understand what i this??

Answers

The splash screen above shows the cursors scheme for El capitan Cursors and shows the instructions on how to install the app. El Capitan Cursors for Windows is third party software that modifies or customizes the way cursors look in Microsoft Windows.

Why are Cursors important?

Douglas Engelbart invented the first computer mouse with a cursor in 1963.

Cursors are important in Windows because they allow users to interact with graphical user interfaces (GUIs) by providing a visual indicator of where actions will take place. Cursors provide feedback to users, indicating what actions are possible and where they can be performed, such as clicking on buttons or selecting text.

Thus, cursors also help to enhance the user experience by providing visual cues that aid in navigation and interaction with the operating system.

Learn more about cursors on:

https://brainly.com/question/12066537

#SPJ1

Rajveer wants to rename column in display result for his query. He has given he
following queries, select correct query for him:
a) select ename, salary*12 Annual Salary from emp;
b) select ename, salary*12 rename “Annual Salary” from emp;
c) select ename, salary * 12 change “Annual Salary” from emp;
d) select ename, salary*12 as “Annual Salary” from emp;

Answers

Answer:

The correct query for Rajveer to rename a column in the display result is:

d) select ename, salary*12 as "Annual Salary" from emp;

Explanation:

In SQL, the AS keyword is used to rename a column in the display result.

The correct syntax for renaming a column is to use the AS keyword followed by the new column name.

In the given query, the AS keyword is used to rename the column as "Annual Salary". The new column name is enclosed in double quotes to indicate that it is a string.

Option (a) is incorrect because it does not rename the column.

Option (b) and (c) are incorrect because there is no rename or change keyword in SQL to rename a column.

Option (d) is the correct query as it uses the AS keyword to rename the column in the display result.

Therefore, option (d) is the correct query for Rajveer to rename a column in the display result.

compare desktop and laptop power suply

Answers

Answer:

hi

Explanation:

in desktop power supply there is a particular wire which powers your pc. in laptop a battery is they which stores the charge and provides power to motherboard. the can battery can be recharged

Explanation:

yeyeyeyeyeyyeyeyeyeyeyye

Other Questions
What would be the MOST immediate effect of competition in car manufacturing?an increase in prices of U.S. carsan increase in U.S. car productionadditional auto workers hired in the U.S.more choices for U.S. consumers Identify the relationship between the angles all other things being equal (ceteris paribus), identify and justify the net impact on the item "NET INCOME"obtained from the Income Statement) of each of the following transactions (analyze each transactioneparately and independently):1. Investment of 100 in land (instantaneous payment).2. Invest 100 on computers with 10-year life and zero residual value.3. Buy raw materials (steel,...) for an amount of 100 .4. Sell, with payment in cash, for 30 materials purchased last year for 20.5. Sell for 30 (in cash) materials purchased this year for 20 .6. Sell for 40 , to be paid in February next year, materials purchased this year for 257. Took a bank loan of 200 for 5 years at a rate of 5% interest Principal to be repaid at the end of 5thyear and accrued interests to be paid by Dec 31" each year.8. Increase wages by 10%. Assume that the total payroll before the rise was 1.000 / year.9. Carried out a capital increase for 150 (immediate payment)Image transcription text The LA Dodgers hit the mosthomeruns in 2014. The number ofhomeruns accounted for 6% of the entireMajor League Baseball homerun count. If 583total homeruns were hit, approximately howmany did the LA Dodgers hit?show work plsss Please help with this math question! where is tan accent 3 lighter 40% in excel? Jai went to the store to buy some chicken. The price per pound of the chicken is $3.75 per pound and he has a coupon for $1.75 off the final amount. With the coupon, how much would Jai have to pay to buy 5 pounds of chicken? Also, write an expression for the cost to buy p pounds of chicken, assuming at least one pound is purchased. Who holds the power to impeach a federal judge? The Death of Mila the Camel Driver Introduction: Before we explore the conditions surrounding Mila's death, let's review some basic facts. We define diffusion as movement of materials from a region of higher concentration to a region of lower concentration. This movement is due to kinetic energy of particles. An example of this can be observed by opening a bottle of perfume. Soon you will smell the perfume in distant parts of the room. It diffuses from the high concentration of molecules in the bottle to a lower concentration of molecules in the air. Osmosis is a type of diffusion. It involves movement of water through a differentially permeable membrane from a region of high concentration (of water molecules) to a region of lower concentration (of water molecules). We define 3 types of solutions based upon osmotic activity. In an isotonic solution, the solute concentration is the same on both sides of the membrane so there is no net movement of water. Use details from the text to determine if the author's viewpoint about the underlined topic is favorable, unfavorable, or neutral. Click and drag the choices to the appropriate box (pls answer ) You are the science officer on a visit to a distant solar system. Prior to landing on a planet you measure its diameter to be 1. 70107 m and its rotation period to be 22. 3 hours. You have previously determined that the planet orbits 2. 701011 m from its star with a period of 402 earth days. Once on the surface you find that the free-fall acceleration is 12. 5 m/s2. A) What is the mass of the planet?B) What is the mass of the star? Which detail best supports the central idea that technology can lead to accessibility for individuals with disabilities?[2] I have been the Director of Assistive Technology at the Anne Carlsen Center for over 25 years. a) The Anne Carlsen Center is a private non-profit center located in North Dakota that serves persons of all abilities throughout the state and region. I started out as a teacher at the center, and early on I realized the power of assistive technologies in providing opportunities for students with special needs. b) Throughout my professional career, I have looked for various ways to provide opportunities for people to realize their full potential. c) I helped host a summer technology camp during which kids from across the state who wouldn't typically be accepted into a traditional camp are provided with access to all types of assistive technologies. d) Once they are able to utilize the devices, we provide them with opportunities to explore music, art, photography, and videography. We also give them the chance to experience typical camping activities such as campfires, pontoon rides, and swimming in a lake. Emmett is planning a party at an escape room. The escape room will charge Emmett a booking fee and an additional cost per person attending the party. This situation can be modeled as a linear relationship. Emmett is planning a party at an escape room. The escape room will charge Emmett a booking fee and an additional cost per person attending the party. This situation can be modeled as a linear relationship. What does the slope of the line tell you about the situation?A. The booking fee is $50 B. After the booking fee the party will cost $20 per personC. After the booking fee the party will cost $25 per personD. Including the bookin fee it would cost emmett $250 total for 10 people to attend How far apart are the two genes in centimorgan? i need help with this problem Hi there,Can you help me? I need help on The given equation involves a power of the variable. Find all real solutions of the equation. (Enter your answers as a comma-separated list. If there is no real solution, enter NO REAL SOLUTION. I don't understand. Can you show your work to understandthank you , in advance3x^5/3 + 96 = 0x = What physical feature makes up most of Israels southern half? Which type of screwdriver has a 1/4" tip and is designed primarily for control panels and working in tight spaces? A. Soft Tip B. Cabinet C. Allen Mario walked at a rate of 2/3 mile every 10 minutes. Big ideas 7.5 question