Answer:
(1) The program in Python is as follows:
rows, cols = (3, 3)
arr =[[0,0,0],[2,2,2],[-2,-2,-2]]
print(arr)
arr[0][0] = 10
arr[2][2] = -10
print(arr)
for i in range(rows):
for j in range(cols):
arr[i][j]-=2
print(arr)
for i in range(rows):
for j in range(cols):
if arr[i][j]< 0:
print(arr[i][j], end = ", ")
(2) The program in Python is as follows:
import numpy as np
x = [10000, 1000, 100, 10, 1, 0, -10, -100]
p = [0.05, 0.05, 0.20, 0.20, 0.1, 0.1, 0.1, 0.2]
q = np.dot(x,p)
print(q)
Explanation:
(1)
This initializes the rows and columns of the array to 3
rows, cols = (3, 3)
1. This creates and array and also populates it with the given data
arr =[[0,0,0],[2,2,2],[-2,-2,-2]]
Print the array
print(arr)
2. This changes index 0,0 to 10 and index 2,2 to -10
arr[0][0] = 10
arr[2][2] = -10
Print the array
print(arr)
This iterates through the rows and the columns of the array
for i in range(rows):
for j in range(cols):
3. This subtracts 2 from each array element
arr[i][j]-=2
Print the array
print(arr)
This iterates through the rows and the columns of the array
for i in range(rows):
for j in range(cols):
If array element is negative
if arr[i][j]< 0:
4. Print the array element
print(arr[i][j], end = ", ")
(2)
Line 1 and 2 are given as part of the program
x = [10000, 1000, 100, 10, 1, 0, -10, -100]
p = [0.05, 0.05, 0.20, 0.20, 0.1, 0.1, 0.1, 0.2]
This uses np dot to multiply x and p
q = np.dot(x,p)
This prints the result of the product
print(q)
Workstations are usually applied for scientific, mathematical, and engineering calculations and computer aided-design and computer aided- manufacturing. a. False b. True
Workstations are usually applied for scientific, mathematical, and engineering calculations and computer aided-design and computer aided- manufacturing is True
What is Workstations?Workstations are specialized computers that are designed for high-performance and resource-intensive tasks such as scientific, mathematical, and engineering calculations, computer-aided design (CAD), and computer-aided manufacturing (CAM).
Therefore, They typically have faster processors, more memory, and better graphics capabilities than general-purpose computers, which allows them to handle the complex tasks required in these fields.
Learn more about Workstations from
https://brainly.com/question/9958445
#SPJ1
Suppose class Person is the parent of class Employee. Complete the following code:
class Person :
def __init__(self, first, last) :
self.firstname = first
self.lastname = last
def Name(self) :
return self.firstname + " " + self.lastname
class Employee(Person) :
def __init__(self, first, last, staffnum) :
Person.__init__(self,first, last) self.staffnumber = staffnum
def GetEmployee(self) :
return self.Name() + ", " + self.staffnumber
x = Person("Sammy", "Student")
y = Employee("Penny", "Peters", "805")
print(x.Name())
print(y.GetEmployee())
Answer:
Explanation:
There is nothing wrong with the code it is complete. The Employee class is correctly extending to the Person class. Therefore, the Employee class is a subclass of Person and Person is the parent class of Employee. The only thing wrong with this code is the faulty structure such as the missing whitespace and indexing which is crucial in Python. This would be the correct format. You can see the output in the picture attached below.
class Person :
def __init__(self, first, last) :
self.firstname = first
self.lastname = last
def Name(self) :
return self.firstname + " " + self.lastname
class Employee(Person) :
def __init__(self, first, last, staffnum) :
Person.__init__(self,first, last)
self.staffnumber = staffnum
def GetEmployee(self) :
return self.Name() + ", " + self.staffnumber
x = Person("Sammy", "Student")
y = Employee("Penny", "Peters", "805")
print(x.Name())
print(y.GetEmployee())
Who takes Mindtap Web Design
Answer:
MindTap is a new personalized program of digital products and services that engages students with interactivity while also offering students and instructors choice in content, platform, devices, and learning tools. ... The customizable, cloud-based system is a web portal students log into to navigate via a dashboard.
Explanation:
MindTap for Minnick's Responsive Web Design with HTML 5 & CSS, 9th Edition is the digital learning solution that powers students from memorization to mastery. It gives you complete control of your course—to provide engaging content, to challenge every individual, and to build their confidence.
The user is able to input grades
and their weights, and calculates the overall final mark. The program should also output what you need to achieve on a specific assessment to achieve a desired overall mark. The program should be able to account for multiple courses as well. Lists are allowed.
Name of person
Number of courses
Course ID
Grades and Weights in various categories (Homework, Quiz, and Tests)
Enter grades until -1 is entered for each category
Final Grade before exam
Calculate to get a desired mark (using final exam)
Output all courses
Answer:
Here is an example of how you could write a program to perform the tasks described:
# Store the student's name and number of courses
name = input("Enter the student's name: ")
num_courses = int(input("Enter the number of courses: "))
# Create an empty list to store the course data
courses = []
# Loop through each course
for i in range(num_courses):
# Input the course ID and initialize the total grade to 0
course_id = input("Enter the course ID: ")
total_grade = 0
# Input the grades and weights for each category
print("Enter grades and weights for each category (enter -1 to finish)")
while True:
category = input("Enter the category (homework, quiz, test): ")
if category == "-1":
break
grade = int(input("Enter the grade: "))
weight = int(input("Enter the weight: "))
# Calculate the contribution of this category to the total grade
total_grade += grade * weight
# Store the course data in a dictionary and add it to the list
course_data = {
"id": course_id,
"grade": total_grade
}
courses.append(course_data)
# Input the final grade before the exam
final_grade_before_exam = int(input("Enter the final grade before the exam: "))
if there is an apple logo on my computer what operating system does it run on
Answer:Mac OS if there is a apple logo
Which of the following components could you add to your network rec to help protect your servers from brown outdoor blackouts an ethernet switch patch panel
Assuming your local area experiences brownouts or blackouts during frequent electrical storms. A component which you could add to your network rack to help protect your servers from brownouts or blackouts include the following: A. UPS.
What is a UPS?In Computer technology, UPS is an abbreviation for Uninterrupted Power Supply and it can be defined as a device that is designed and developed to with an enhanced battery system, in order to allow a computer and other electrical devices to keep running and functioning for at least a short time in the event of a power disruption or when the incoming (input) power is interrupted.
Generally speaking, a short-term decrease in electrical power availability is typically referred to as a brownout.
In order to protect a network equipment such as a router, server, or switch from brownouts or blackouts during frequent electrical storms, you must add an Uninterrupted Power Supply (UPS) to your network rack.
Read more on power here: https://brainly.com/question/23438819
#SPJ1
Complete Question:
Your local area experiences brownouts or blackouts during frequent electrical storms. Which of the following components could you add to your network rack to help protect your servers from brownouts or blackouts?
UPS
Ethernet switch
Patch panel
Wireless controller
Identifying How to Print a Record on One Page
Which property ensures that all of the details for a record will be printed on the same page, instead of being broken
up between two pages during printing?
O the Control Source property
the Force New Page property
O the Keep Together property
o the Page Break property
Answer:
C) The Keep Together Property
Explanation:
Apply _____ to help readers spot trends and patterns in data.Immersive Reader
(1 Point)
wide margins on a printout
conditional formatting
gridlines to the worksheet
a theme to the worksheet
Answer: conditional formatting
Explanation:
Conditional formatting is typically seen in spreadsheet applications and it enables one to be able to apply formatting to cells which meet s particular criteria.
It can be used to highlight data or information and also enable the readers to spot trends and patterns in data.
, emphasize, or differentiate among data and information stored in a
a.) Software architecture is the set of principal design decisions about a system. b.) Software architecture dictates the process used by a team to develop use cases for a software system c.) Software architecture serves as the blueprint for construction and evolution of a software system d.) Software architecture is the clear definition of multiple high-level components that, when working together, form your system and solve your problem e.) All of the above statements are true.
Question:
Which of the following statements is not a true statement about software architecture?
Answer:
b.) Software architecture dictates the process used by a team to develop use cases for a software system.
Explanation:
A software development life cycle (SDLC) can be defined as a strategic process or methodology that defines the key steps or stages for creating and implementing high quality software applications. There are six (6) main stages in the creation of a software and these are;
1. Planning.
2. Analysis.
3. Design.
4. Development (coding).
5. Deployment.
6. Maintenance.
One of the most important steps in the software development life cycle (SDLC) is design. It is the third step of SDLC and comes immediately after the analysis stage.
Basically, method design is the stage where the software developer describes the features, architecture and functions of the proposed solution in accordance with a standard.
Software architecture can be defined as the software blueprint or infrastructure in which the components (elements) of the software providing user functionality and their relationships are defined, deployed and executed. Thus, it is a structured framework used by software developers to model software components (elements), properties and relationships in order to have a good understanding of how the program would behave.
In conclusion, software architecture doesn't dictate the process used by a team to develop use cases for a software system.
What is the main difference between a goal and an objective?
A goal is a broad-based projection, and an objective is a set of benchmarks.
A goal is a broad-based projection, and an objective is a specific accomplishment.
A goal is a broad-based projection, and an objective is a set of mini-goals.
A goal is a measurable projection, and an objective is a specific accomplishment
A goal is a desired outcome, but an objective is a targeted action that may be completed quickly and is frequently tied to a goal.
Give an example of each and explain the difference between an objective and a goal.Objectives are specified in terms of measurable, tangible targets, whereas goals can be immaterial and unmeasurable. For instance, while "offering great customer service" is an intangible goal, "reducing the client wait time to one minute" is a tangible goal that contributes to the achievement of the primary goal.
What distinguishes educational goals from objectives?Learning In contrast to aims, which convey a broad declaration of intent, objectives are specific, distinct intentions of student performance. Goals cannot be measured or seen; however, objectives can.
to know more about goals and an objective here:
brainly.com/question/28017832
#SPJ1
An organization has hired a new remote workforce. Many new employees are reporting that they are unable to access the shared network resources while traveling. They need to be able to travel to and from different locations on a weekly basis. Shared offices are retained at the headquarters location. The remote workforce will have identical file and system access requirements, and must also be able to log in to the headquarters location remotely. Which of the following BEST represent how the remote employees should have been set up initially?
a. User-based access control
b. Shared accounts
c. Group-based access control
d. Roaming profiles
e. Individual accounts
Answer:
A
Explanation:
Ez put me as brainlist
Code to be written in python:
Correct answer will be automatically awarded the brainliest!
Since you now have a good understanding of the new situation, write a new num_of_paths function to get the number of ways out. The function should take in a map of maze that Yee Sian sent to you and return the result as an integer. The map is a tuple of n tuples, each with m values. The values inside the tuple are either 0 or 1. So maze[i][j] will tell you what's in cell (i, j) and 0 stands for a bomb in that cell.
For example, this is the maze we saw in the previous question:
((1, 1, 1, 1, 1, 1, 1, 1, 0, 1),
(1, 0, 0, 1, 1, 1, 0, 0, 1, 1),
(0, 1, 1, 1, 0, 0, 1, 1, 1, 0),
(1, 1, 0, 1, 1, 1, 1, 0, 1, 1),
(0, 1, 0, 1, 0, 0, 1, 0, 1, 0),
(1, 0, 1, 1, 1, 1, 0, 1, 1, 1),
(0, 1, 1, 1, 1, 1, 1, 1, 1, 0),
(1, 0, 1, 0, 0, 1, 1, 0, 1, 1),
(1, 0, 1, 1, 1, 0, 1, 0, 1, 0),
(1, 1, 0, 1, 0, 1, 0, 1, 1, 1))
Note: You should be using dynamic programming to pass time limitation test.
Hint: You might find the following algorithm useful:
Initialize an empty table (dictionary), get the number of rows n and number of columns m.
Fill in the first row. For j in range m:
2.1 If maze[0][j] is safe, set table[(0, j)] to be 1 because there's one way to go there.
2.2 If maze[0][j] has a bomb, set table[(0, k)] where k >= j to be 0. Since one cell is broken along the way, all following cells (in the first row) cannot be reached.
Fill in the first column. For i in range n:
3.1 If maze[i][0] is safe, set table[(i, 0)] to be 1 because there's one way to go there.
3.2 If maze[i][0] has a bomb, set table[(i, 0)] and all cells under it to be 0. The reason is same as for the first row.
Main dynamic programming procedure - fill in the rest of the table.
If maze[i][j] has a bomb, set table[(i, j)] = 0.
Otherwise, table[(i, j)] = table[(i - 1, j)] + table[(i, j - 1)]
Return table[(n - 1, m - 1)]
Incomplete code:
def num_of_paths(maze):
# your code here
# Do NOT modify
maze1 = ((1, 1, 1, 1, 1, 1, 1, 1, 0, 1),
(1, 0, 0, 1, 1, 1, 0, 0, 1, 1),
(0, 1, 1, 1, 0, 0, 1, 1, 1, 0),
(1, 1, 0, 1, 1, 1, 1, 0, 1, 1),
(0, 1, 0, 1, 0, 0, 1, 0, 1, 0),
(1, 0, 1, 1, 1, 1, 0, 1, 1, 1),
(1, 1, 0, 1, 0, 1, 0, 0, 1, 1),
(0, 1, 1, 1, 1, 1, 1, 1, 1, 0),
(1, 0, 1, 0, 0, 1, 1, 0, 1, 1),
(1, 0, 1, 1, 1, 0, 1, 0, 1, 0),
(1, 1, 0, 1, 0, 1, 0, 1, 1, 1))
maze2 = ((1, 1, 1, 1, 1, 1, 1, 1, 1),
(1, 1, 1, 1, 1, 1, 1, 1, 1),
(1, 1, 1, 1, 1, 1, 1, 1, 1),
(1, 1, 1, 1, 1, 1, 1, 1, 1),
(1, 1, 1, 1, 1, 1, 1, 1, 1),
(1, 1, 1, 1, 1, 1, 1, 1, 1),
(1, 1, 1, 1, 1, 1, 1, 1, 1))
maze3 = ((1, 0, 1, 1),
(1, 0, 1, 1),
(1, 0, 1, 1),
(1, 0, 1, 1),
(1, 0, 1, 0),
(1, 0, 0, 1))
Test Cases:
num_of_paths(maze1) 2
num_of_paths(maze2) 3003
num_of_paths(maze3) 0
The user is able to input grades and their weights, and calculates the overall final mark. The program should also output what you need to achieve on a specific assessment to achieve a desired overall mark. The program should be able to account for MULTIPLE COURSES as well.
I have done some pseudocode. So to double check, please provide pseudocode and python code.
I do plan to use homework, quizzes and tests for the grades portion and using the exam as part of the desired mark portion.
Please follow the instructions above. LISTS are allowed to be used.
Answer:
def calculate_final_mark(courses):
final_mark = 0
total_weight = 0
for course in courses:
final_mark += course['mark'] * course['weight']
total_weight += course['weight']
return final_mark / total_weight
def calculate_required_mark(courses, desired_mark):
current_mark = calculate_final_mark(courses)
total_weight = 0
for course in courses:
total_weight += course['weight']
required_mark = (desired_mark - current_mark) / (1 - total_weight)
return required_mark
# Example usage:
courses = [
{'name': 'Math', 'mark': 80, 'weight': 0.4},
{'name': 'Science', 'mark': 70, 'weight': 0.3},
{'name': 'English', 'mark': 65, 'weight': 0.3},
]
final_mark = calculate_final_mark(courses)
print(f"Your final mark is {final_mark:.1f}")
desired_mark = 80
required_mark = calculate_required_mark(courses, desired_mark)
print(f"You need to score at least {required_mark:.1f} on your next assessment to achieve a final mark of {desired_mark}")
Code to be written in python:
Correct answer will automatically be awarded the brainliest.
One of the senior wizards Yee Sian was trapped in a maze during a mission. The maze has n * m cells, labelled from (0, 0) to (n-1, m-1). Starting at cell (0, 0), each time Yee Sian can only take one step, either to the right or down. We wish to find out the number of possible paths to the destination (n - 1, m - 1). A sample path is shown in the figure below.
Having learnt the technique of speeding up the pascal function through memoization, you decide to apply it here. If Yee Sian can walk out by himself (number of paths > 0), tell him how many ways there are. Otherwise, report to Grandwizard and send a rescue team.
Write a function num_of_paths that takes in two integers representing the number of rows (n) and columns (m) in a maze and returns an integer value of number of paths from cell (0, 0) to cell (n - 1, m - 1). The table and skeleton code are given to you. Your table is essentially a dictionary that stores (i, j): val pairs which indicate the number of paths from cell (0, 0) to cell (i, j).
Note: You may assume that all inputs n and m are valid. i.e. n > 0, m > 0.
Incomplete Code:
table = {} # table to memoize computed values
def num_of_paths(n, m):
# your code here
pass
Test Cases:
num_of_paths(1, 100) 1
num_of_paths(123, 1) 1
num_of_paths(3, 3) 6
num_of_paths(10, 10) 48620
num_of_paths(28, 56) 3438452994457305131328
Which learners like to be outside and are good at preservation, conservation, and organizing a living area?
A naturalistic learner likes to be outside and is good at preservation, conservation, and organizing a living area The correct option is a.
What is a naturalistic learner?Naturalistic Learners are students who have strengths in intelligence related to nature. They may be highly connected to nature in many ways: They may have a deep love of plants, animals, people, rocks, nature, being outdoors, camping, hiking, rock climbing, biology, astrology, dinosaurs, etc
Naturalistic learners enjoy nature and being outside, as the name suggests. They learn best outside and can easily connect with concepts centered on plants, animals, and the environment.
Therefore, the correct option is a, naturalistic learner.
To learn more about naturalistic learner, visit here:
https://brainly.com/question/8233227
#SPJ1
The question is incomplete. Your most probably complete question is given below:
naturalistic learner
kinesthetic learners
visual learners
aural Learners
17. Which of the following is NOT a contributing factor to the lasting popularity of League of Legends?
a) The game is free
b) Professional gamers can compete in televised tournaments that award cash prizes
c) Players can customize the characters and their behavior
d) Simple graphics and visuals that don’t distract from the goal of the game
Answer:
c?
Explanation:
what do you understand by statistic
Statistics is the study and manipulation of data, including methods for data collection, evaluation, analysis, and interpretation.
Describe statistics using an example.Finding out how many people in a town watch TV relative to the overall population of the town is an example of statistical analysis. Here, the small group of individuals drawn from the population is referred to as the sample.
What are types and statistics?Statistics is a technique for interpreting, analyzing, and summarizing data in mathematics. In light of these characteristics, the various statistical types are divided into: Statistics that are descriptive and inferential. We analyze and understand data based on how it is presented, such as using pie charts, bar graphs, or tables.
To know more about statistics visit:-
https://brainly.com/question/29093686
#SPJ1
solve the MRS y,x = 12 mean?
Answer:
Explanation:
The MRS (Marginal Rate of Substitution) is a concept from microeconomics that describes the rate at which one good (in this case, y) can be substituted for another good (in this case, x) while still maintaining the same level of utility or satisfaction for the consumer.
The equation you provided, MRS y,x = 12, tells us that in order for a consumer to maintain the same level of satisfaction, they would be willing to give up 12 units of good y in exchange for 1 unit of good x. This means that, in this specific case, the consumer values good y 12 times more than good x.
It's important to keep in mind that the MRS is a concept that can vary depending on the context and the consumer. The value of the MRS can change depending on the consumer's preferences, the availability of the goods, and the prices of the goods, among other factors.
On this equation alone, I can't confirm what exactly it refers to as more information about the context and the goods themselves is needed, also to make this equation valuable, it's should be done in a utility function or optimization problem in order to give some meaning to the number 12.
Agreeing to third parties' terms of service
- you have removed your digital footprint
-means they can view your information
-means they will protect your information
-tends to result in free gifts
Answer: the answer is c - means they can view your information i took the assignment for edgunity
Explanation: i took the assignment for edgunity
How BFS takes more memory than DFS?
Answer:
The BFS have to track of all nodes on the same level
which of the following are considered as bad data
Answer:
where is the answer?????
see the explanation and find the answer
Bad data is an inaccurate set of information, including missing data, wrong information, inappropriate data, non-conforming data, duplicate data and poor entries (misspells, typos, variations in spellings, format etc).
Will mark brainliest if correct!
Code to be written in python
A deferred annuity is an annuity which delays its payouts. This means that the payouts do not start until after a certain duration. Notice that a deferred annuity is just a deposit at the start, followed by an annuity. Your task is to define a Higher-order Function that returns a function that takes in a given interest rate and outputs the amount of money that is left in a deferred annuity.
Define a function new_balance(principal, gap, payout, duration) that returns a single-parameter function which takes in a monthly interest rate and outputs the balance in a deferred annuity. gap is the duration in months before the first payment, payout is monthly and duration is just the total number of payouts.
Hint: Note that duration specifies the number of payouts after the deferment, and not the total duration of the deferred annuity.
def new_balance(principal, gap, payout, duration):
# Complete the function
return
# e.g.
# test_balance = new_balance(1000, 2, 100, 2)
# result = test_balance(0.1)
Test Case:
new_balance(1000, 2, 100, 2)(0.1) 1121.0
Answer:
def new_balance(principal, gap, payout, duration):
def calculate_balance(interest_rate):
balance = principal
for i in range(gap):
balance *= (1 + interest_rate/12)
for i in range(duration):
balance *= (1 + interest_rate/12)
balance -= payout
return balance
return calculate_balance
Explanation:
Answer:
def new_balance(principal, gap, payout, duration):
# convert monetary amounts to cents
principal_cents = principal * 100
payout_cents = payout * 100
def balance(rate):
# calculate the interest earned during the deferment period in cents
interest_cents = principal_cents * (1 + rate) ** gap - principal_cents
# calculate the balance after the first payout in cents
balance_cents = interest_cents + principal_cents - payout_cents
# loop through the remaining payouts, calculating the balance after each one in cents
for i in range(duration - 1):
balance_cents = balance_cents * (1 + rate) - payout_cents
# convert the balance back to dollars and round it to the nearest cent
balance_dollars = round(balance_cents / 100)
return balance_dollars
return balance
test_balance = new_balance(1000, 2, 100, 2)
result = test_balance(0.1)
print(float(result))
If You're is in credit card debt, why can't you just say your card was stolen so you can avoid the debt.
Specifications and Cloud Service Providers will be given. (a) You have to find the best provider (b) Determine the cost using THREE BIG cloud providers in the world (c) In case of any failure how you handle.
Your team has a unified view of every customer, from their initial click to their final call, thanks to Service Cloud. By viewing all customer information and interactions on one screen, handling time can be decreased.
Who are the top three providers of cloud services?The three cloud service providers with the greatest market shares—Web Services (AWS), Azure, and Cloud Platform (GCP)—acquire approximately 65% of the money spent on cloud infrastructure services.
Which services do cloud service providers offer in total?Cloud computing refers to the delivery of services including networking, storage, servers, and databases over the internet. It is a novel approach to resource provisioning, application staging, and platform-agnostic user access to services.
to know more about Specifications and Cloud Service here:
brainly.com/question/29707159
#SPJ1
The cost of 5/2 kg sugar is Rs. 235/4. What is the cost of 1 kg sugar ? *l
Answer:
23.5
Explanation:
Explain afew of the different ways in which computers can be categorised
Write a Java program for user defined exception that checks the internal and external marks; if the internal marks is greater than 30 it raises the exception “Internal mark exceeded”; if the external marks is greater than 70 it raises the exception and displays the message “External mark exceeded”, Create the above exception and test the exceptions.
Answer:
class MarksException extends Exception {
public MarksException(String message) {
super(message);
}
}
public class Main {
public static void main(String[] args) {
try {
checkMarks(35, 80);
} catch (MarksException e) {
System.out.println(e.getMessage());
}
}
public static void checkMarks(int internal, int external) throws MarksException {
if (internal > 30) {
throw new MarksException("Internal mark exceeded");
}
if (external > 70) {
throw new MarksException("External mark exceeded");
}
}
}
Explanation:
Consider the following instance variables and incomplete method that are part of a class that represents an item. The variables years and months are used to represent the age of the item, and the value for months is always between 0 and 11, inclusive. Method updateAge is used to update these variables based on the parameter extraMonths that represents the number of months to be added to the age.
private int years;
private int months; // 0 <= months <= 11
public void updateAge(int extraMonths)
{
/* body of updateAge */
}
Which of the following code segments shown below could be used to replace /* body of updateAge */ so that the method will work as intended?
I int yrs = extraMonths % 12;
int mos = extraMonths / 12;
years = years + yrs;
months = months + mos;
II int totalMonths = years * 12 + months + extraMonths;
years = totalMonths / 12;
months = totalMonths % 12;
III int totalMonths = months + extraMonths;
years = years + totalMonths / 12;
months = totalMonths % 12;
a. I only
b. II only
c. III only
d. I and II only
e. II and III
Answer:
e. II and III
Explanation:
Given
The above code segment
Required
Which can complete the updateAge() method
From the program we understand that the updateAge() will update the year and month based on the extraMonths passed to it.
For instance
[tex]years = 6[/tex] and [tex]months = 8[/tex]
updateAge(5) will update years to 7 and month 1
Having established that, next we analyze options I, II and III
Code I
1. This divides extraMonths by 12 and saves the remainder in yrs.
For instance: 15 months = 1 year and 3 months. So:
[tex]yrs = 3[/tex]
2. This divides extraMonths by 12 and saves the whole part in mos
For instance: 15 months = 1 year and 3 months. So:
[tex]mos = 1[/tex]
3. This updates the value of years by the result of 1 (i.e. the remaining months)
4. This updates the value of years by the result of 2 (i.e. the remaining years)
[tex]months = months + mos;[/tex]
Conclusion:, (I) is incorrect because years and months were updated with the wrong values
Code II
1. This converts years to months, then add the result of the conversion to extraMonths + month
For instance: [tex]years = 3; months = 6; extraMonths = 15[/tex]
[tex]totalMonths = 3 * 12 + 6 + 15 = 57\ months[/tex]
2. This calculates the number of years in totalMonths
[tex]years = totalMonths / 12;[/tex]
i.e [tex]years = 57/12 = 4[/tex]
3. This divides totalMonths by 12 and saves the remainder in months
[tex]months = totalMonths \% 12;[/tex]
i.e. [tex]months = 57\%12 = 9[/tex]
Rough Calculation
[tex]years = 3; months = 6; extraMonths = 15[/tex]
[tex]3\ years + 6\ months + 15\ months = 4\ years\ 9\ months[/tex]
Conclusion: Code II is correct
Code III
1. This calculates the total months
For instance: [tex]years = 3; months = 6; extraMonths = 15[/tex]
[tex]totalMonths = 6 + 15 = 21\ months[/tex]
2. This calculates the number of years in totalMonths, then add the result ot years
[tex]years = years + totalMonths / 12;[/tex]
i.e. [tex]years = 3 + 21/12 = 3 + 1 = 4[/tex]
3. This divides totalMonths by 12 and saves the remainder in months
[tex]months = totalMonths \% 12;[/tex]
i.e. [tex]months = 21\%12 = 9[/tex]
Rough Calculation
[tex]years = 3; months = 6; extraMonths = 15[/tex]
[tex]3\ years + 6\ months + 15\ months = 4\ years\ 9\ months[/tex]
Conclusion: Code III is correct
Write a class called Rational with a constructor Rational(int, int) that takes two integers, a numerator and a denominator, and stores those two values in reduced form in corresponding private members. The class should have a private member function void reduce() that is used to accomplish the transformation to reduced form. The class should have an overloaded insertion operator << that will be used for output of objects of the class.
Answer:
The program in C++ is as follows:
class Rational {
public:
void reduce(int num, int denom) {
int d = __gcd(num, denom);
num /= d;
denom /= d;
cout << "Fraction: " << num <<"/" << denom << endl;
}
int num; int denom;
};
int main() {
int numerator, denominator;
cout<<"Numerator: "; cin>>numerator;
cout<<"Denominator: "; cin>>denominator;
Rational myObj;
myObj . num = numerator;
myObj . denom = denominator;
myObj . reduce(myObj . num,myObj . denom);
return 0;
}
Explanation:
In order to be able to submit my solution, I had to remove and alter some parts of the program.
I've added the complete program as an attachment where I used comments to explain each line of the program
gawain sa pagkatuto bilang 1 isipin mong ikaw ay dsa isang patimpalak sa pagsulat ng sanaysay sa inyong paaralan at binigyan ka ng isang form na dapat mong punan ng impormasyon tungkol sa iyong sarili. punan mo itong wastong impormasyon brainly .
Answer:
Isang pangalan ngayon at kailan ang sagot thank you ❤️❤️❤️❤️