The C++ program uses hierarchal inheritance to calculate the sum of odd or even numbers based on user choice, utilizing a base class and two derived classes for odd and even numbers respectively.
Here's the C++ program that implements hierarchal inheritance to calculate the sum of odd or even numbers based on the user's choice:
```cpp
#include <iostream>
class Numbers {
protected:
int n;
public:
void read() {
std::cout << "Enter the value of 'n': ";
std::cin >> n;
}
};
class DerivedClass1 : public Numbers {
public:
void odd_sum() {
int sum = 0;
for (int i = 1; i <= n; i += 2) {
sum += i;
}
std::cout << "Sum of odd numbers until " << n << ": " << sum << std::endl;
}
};
class DerivedClass2 : public Numbers {
public:
void even_sum() {
int sum = 0;
for (int i = 2; i <= n; i += 2) {
sum += i;
}
std::cout << "Sum of even numbers until " << n << ": " << sum << std::endl;
}
};
int main() {
int choice;
std::cout << "Enter the choice (1 - sum of odd numbers, 2 - sum of even numbers): ";
std::cin >> choice;
if (choice != 1 && choice != 2) {
std::cout << "Invalid choice" << std::endl;
return 0;
}
Numbers* numbers;
if (choice == 1) {
DerivedClass1 obj1;
numbers = &obj1;
} else {
DerivedClass2 obj2;
numbers = &obj2;
}
numbers->read();
if (choice == 1) {
DerivedClass1* obj1 = dynamic_cast<DerivedClass1*>(numbers);
obj1->odd_sum();
} else {
DerivedClass2* obj2 = dynamic_cast<DerivedClass2*>(numbers);
obj2->even_sum();
}
return 0;
}
```
1. The program defines a base class "Numbers" with a public member variable 'n' and a member function "read()" to read the value of 'n' from the user.
2. Two derived classes are created: "DerivedClass1" and "DerivedClass2", which inherit from the base class "Numbers".
3. "DerivedClass1" has a public member function "odd_sum()" that calculates the sum of odd numbers until 'n'.
4. "DerivedClass2" has a public member function "even_sum()" that calculates the sum of even numbers until 'n'.
5. In the main function, the user is prompted to enter their choice: 1 for the sum of odd numbers or 2 for the sum of even numbers.
6. Based on the user's choice, an object of the corresponding derived class is created using dynamic memory allocation and a pointer of type "Numbers" is used to refer to it.
7. The "read()" function is called to read the value of 'n' from the user.
8. Using dynamic casting, the pointer is cast to either "DerivedClass1" or "DerivedClass2", and the corresponding member function ("odd_sum()" or "even_sum()") is called to calculate and print the sum.
Note: The program validates the user's choice and handles invalid inputs by displaying an appropriate error message.
Learn more about dynamic casting here: brainly.com/question/32294285
#SPJ11
How has technology effected the way we communicate?
Indeed it has.
Advancements in technology and changes in communication generally go hand in hand. Landlines displaced the telegraph and cell phones replaced landlines. The arrival of the internet opened new doors of personal communication. E-mails replaced postal mails and social media took the place of text messages.
Communication technology, such as mobile phones, email, text messaging, instant messaging and social networking have had a profound effect on nearly everyone's business and personal lives. While technology makes communications faster and easier, at times it can also be intrusive and misinterpreted.
Increased isolation, reduced social interaction and social skills, and increased human-to-machine interactions are all a result of an overuse of technology, which has created a wall between many people globally.
Technology has the ability to enhance daily living from appliances to mobile devices and computers, technology is everywhere. ... In the rise of digital communication, technology can actually help communication skills because it allows people to learn written communication to varying audiences.
-Astolfo
what job titles describes a person with green engery? in career clusters
Answer:
environmental scientist
Explanation:
33.3% complete question an employee is responsible for protecting the privacy and rights of data used and transmitted by an organization. the employee dictates the procedures and purpose of data usage. a role is created at an organization to protect the privacy and rights of any data that is used and transmitted. which role governs and dictates the procedures and purpose of data usage
An organization designates a position to safeguard the rights and privacy of any utilized and transmitted data. The function of the data controller sets rules and requirements for how data is used.
The person in charge of personal processing data chooses the objectives and methods for doing so. Therefore, the data controller is your firm or organization if it determines "why" and "how" the personal data should be handled. To carry out your duties as the data controller, employees in your organization process personal data.
If you and one or more other organizations jointly decide "why" and "how" personal data should be processed, your firm or organization is a joint controller. Joint controllers must establish an agreement outlining their individual responsibilities for adhering to GDPR regulations. The individuals whose data is being processed must be informed of the main details of the arrangement.
The data processor only processes personal data on behalf of the controller.
Learn more about data controller here:
https://brainly.com/question/23129165
#SPJ4
JAVA Write code that asks for a positive integer n, then prints 3 random integers from 2 to n+2 inclusive using Math. Random().
Note #1: In the starter code for this exercise the line "import testing. Math;" appears. You should not remove this line from your code as it is required to correctly grade your code. Also make sure that your code outputs exactly 3 numbers (be particularly careful there aren't any extra numbers in your prompt for user input).
Note #2: Make sure your minimum output is 2 or more and make sure your maximum output is only up to n + 2 (so if user inputs 5, the maximum output should only be 7). Hint: Knowing your PEMDAS will help a lot.
Sample Run: Enter a positive integer: 6 7 2 5
The program for the positive integer is illustrated thus:
/*Importing Necessary Classes*/
import java.util.*;
/*Note : Comment This Line Of Code If you Want to Run the Code in your IDE*/
import testing.Math;/*Note : Comment This Line Of Code If you Want to Run the Code in your IDE*/
/*Note : Comment This Line Of Code If you Want to Run the Code in your IDE*/
/*Declaring A Public Class*/
public class Main{
/*Declaring Main Method Execution Starts From Here*/
public static void main(String[] args){
/*Declaring a startFrom int Variable to Store the starting value*/
int startFrom = 2;
/*Declaring a endAt int Variable to Store the End Value value*/
int endAt;
How to illustrate the program?We first import the necessary classes that will be utilized by the program.
We must now declare the Main class as a public class. Execution begins after declaring a Main Method inside the Public Main Class.
Next, declare an int variable called startFrom to store the starting value.
Next, create an int variable named endAt to store the end value. Next, declare an int variable named randomNumber to hold the random value. Here, creating a Scanner Class object to receive input from the user
Learn more about program on:
https://brainly.com/question/26642771
#SPJ1
Why is a disorganized room considered a study distraction? Check all that apply.
-Clutter is distracting.
-Students waste time searching for supplies.
-It is nearly impossible to read in messy spaces.
-Disorganized rooms are poorly lit.
-Important papers can get lost.
-Study materials and books can get misplaced.
Answer:-Clutter is distracting.
-Students waste time searching for supplies.
-Important papers can get lost.
-Study materials and books can get misplaced.
Explanation:
Answer:
A,B,E,F
Explanation:
Clutter is distracting.
Students waste time searching for supplies.
Important papers can get lost.
Study materials and books can get misplaced.
How do u kiss someone and not feel werid about it afterwards
Answer: just don't kiss someone
Explanation: easy, but if you do then just leave. duh
decimal numbers is equivalent to binary 110
Answer:
yes it is
Explanation:
binary number is 1101110
Usability is _____.
a debugging technique that uses print statements to trace the program flow
a debugging technique that uses print statements to trace the program flow
the degree to which a program meets the needs of a user, including but not limited to learnability, reliability, and ease of use
the degree to which a program meets the needs of a user, including but not limited to learnability, reliability, and ease of use
a testing method that uses a program that tests another program
a testing method that uses a program that tests another program
conforming to accepted standards of behavior
conforming to accepted standards of behavior
Answer:
C) Usability is a testing method that uses a program that tests another program.
Explanation:
Hope it helps! =D
Answer: the degree to which a program meets the needs of a user, including but not limited to learnability, reliability, and ease of use
what statement can cause immediate exit from the try block and the execution of an exception handler
Raise statement causes immediate exit from the try block and the execution of an exception handler. The exception handler prints the argument passed by the raise statement that causes execution to occur. It's important to note that the normal flow of code is not obscured by new if-else statements.
How does raise statement works?The raise statement stops normal execution of a PL/SQL block or subprogram and transfers control to an exception handler. Raise statements can raise predefined exceptions, such as ZERO_DIVIDE or NO_DATA_FOUND, or user-defined exceptions whose names you decide. Raise statement can be applied to Procedural Language/Structured Query Language (PL/SQL)
Learn more about PL/SQL https://brainly.com/question/28249074
#SPJ4
What six things can you do with GIS?
Answer:
You can:
- Change detection
- Transport route planning
- Flood risk mapping
- Site selection
- Weed and pest management
- Koala habitat mapping
Hope this helps! :)
Which of the following best describes what a long-term goal is?
for which user or users can you control access to app1 by using a conditional access policy?
Conditional Access App Management offers real-time monitoring and control of user app access and sessions based on access and session policies.
The Defender for Cloud Apps interface uses access and session policies to establish actions to be executed on a user and further refine filters. A set of policies and configurations called conditional access regulates which devices have access to certain services and data sources. Conditional access is compatible with the Office 365 product line and SaaS apps that are set up in Azure Active Directory in the Microsoft environment. Conditional Access App Management offers real-time monitoring and control of user app access and sessions based on access and session policies.
Learn more about conditional here-
https://brainly.com/question/15000185
#SPJ4
automation of as many of the manufacturing processes as possible is one of the benefits of:___________.
One of the advantages of computer integrated manufacturing is the ability to automate as many production processes as feasible.
Automation decreases labor expenses since most manual operations are mechanized. AI and data analytics contribute to lower manufacturing costs by giving insights and data that allow for prompt and educated decisions. Lower operational expenses result from less mistakes and waste. In sectors as diverse as heavy machinery and light electronics, a typical automated manufacturing system may conduct activities such as machining, welding, inspection, and assembly. Computer-interfaced machine tools, robotics, and automated material-handling and storage systems are among its components. Productivity is increased via industrial automation. The digitization of industry, particularly the introduction of the Industrial Internet of Things (IIoT), also implies improved through put and reduced downtime as gear is used and maintained more efficiently.
Learn more about data analytics from here;
https://brainly.com/question/23860654
#SPJ4
Pls help me!! I will give 35 points and mark brainliest !!!
Answer:I don’t see anything I’m so confused
Explanation:
What are the Positive and negative sites of the internet
Answer:
A positive of the sites of internet is that it can be very helpful to you like brainly. It can also educate you and help when you cant do you something like we have online classes since we can't go to school because of Corona
A negative of the sites of the internet is that sometimes people will try to trick you to do irresponsible things. Some will trick you for your address, credit card number, or using things unwisely. Because people don't know who is behind the screen they might be a criminal but they also don't know who you are until they get your address or information.
Explanation:
Placing parenthesis around a word, in a search, provides an exact match to that word
in the results.
True
False
Answer:
Explanation:
Placing parenthesis around a word, in a search, provides an exact match to that word in the results.
True
What is the default file system used by Windows 7?A. FAT32B. CDFSC. NTFSD. FAT
The default file system used by Windows 7 is NTFS (New Technology File System).
Option C. NTFS is correct.
The default file system used by Windows 7 is NTFS (New Technology File System).
NTFS was introduced by Microsoft in 1993 as an improvement over the older FAT (File Allocation Table) file system. NTFS is a more advanced and robust file system that supports larger files and provides better security and data reliability.
NTFS offers several advantages over FAT, such as support for larger file sizes, improved performance, better security, and more efficient use of disk space.
With NTFS, you can store files larger than 4GB, which is the maximum file size supported by FAT32. This is especially useful for users who work with large media files, such as videos, images, and audio files.
Another advantage of NTFS is its support for advanced security features such as file and folder permissions, encryption, and auditing.
This allows users to set permissions on individual files and folders, control who can access them, and track changes made to them.
NTFS also supports journaling, which means that file system changes are logged to a journal file before they are written to disk.
This helps prevent data loss in case of a power failure or system crash.
In summary, NTFS is the default file system used by Windows 7, and it offers several advantages over the older FAT file system.
NTFS provides better performance, larger file size support, enhanced security, and more efficient use of disk space, making it the preferred choice for modern Windows operating systems.
For similar question on Windows 7.
https://brainly.com/question/30438692
#SPJ11
Months Write a program that will ask the user for a month as input in numeric format and print out the name of the month. Here is a sample run: Enter the Month: 9 It is september!
The program prompts the user to enter a month in numeric format and then prints the corresponding name of the month. For example, if the user enters 9, the program will output "It is September!" as the result.
To implement this program in Python, we can define a dictionary that maps numeric month values to their corresponding names. The program will ask the user to input a numeric month value. It will then retrieve the corresponding month name from the dictionary and print it along with a message. Here's an example implementation:
def print_month_name():
month_dict = {
1: "January",
2: "February",
3: "March",
4: "April",
5: "May",
6: "June",
7: "July",
8: "August",
9: "September",
10: "October",
11: "November",
12: "December"
}
month_number = int(input("Enter the Month: "))
if month_number in month_dict:
month_name = month_dict[month_number]
print("It is", month_name + "!")
else:
print("Invalid month number.")
print_month_name()
In this program, the dictionary month_dict maps numeric month values (keys) to their corresponding month names (values). The program prompts the user to enter a month number. If the entered number exists as a key in the dictionary, the corresponding month name is retrieved and printed along with the message "It is [month name]!". If the entered number is not found in the dictionary, an error message is displayed.
Learn more about Python here: https://brainly.com/question/30427047
#SPJ11
Drag the tiles to the correct boxes to complete the pairs.
Match each label to its description.
worm
virus
Trojan horse
acts as a legitimate program and infects your computer when you run it
arrowRight
is an independent program that propagates through the network to infect computers
arrowRight
attaches to a software program and infects your computer, destroying your files
Worms are independent programs that propagate through the network to infect computers. They are designed to spread quickly through a network, replicating themselves on other machines and causing a variety of problems.
Viruses are the most common form of malware. They can attach to a software program and infect your computer, destroying your files.
Once the Trojan horse infects your computer, it can cause a variety of problems, including stealing data, corrupting files, or downloading additional malware.
In computing, malware is any software intentionally designed to harm a computer system, server, client, or computer network. Some of these malicious programs can steal data, encrypt files, and disrupt system operations. The malware is often used to take over computer systems, collect data, or disrupt normal operations.
It can be a single program or a combination of different programs that work together to cause damage to a computer. This article will discuss three common types of malware and how they infect your computer.
Worms are independent programs that propagate through the network to infect computers. They are designed to spread quickly through a network, replicating themselves on other machines and causing a variety of problems. Some worms can delete files or shut down critical services, while others are designed to create a botnet, which is a network of compromised computers that can be used for malicious purposes.
Viruses are the most common form of malware. They can attach to a software program and infect your computer, destroying your files. A virus is designed to spread from one computer to another and can be spread through email attachments, file-sharing networks, or by visiting an infected website.
Once the virus infects your computer, it can cause a variety of problems, including corrupting files, deleting data, or crashing your system. A Trojan horse is a type of malware that acts as a legitimate program and infects your computer when you run it. It is often disguised as a useful program, such as a game or a utility, and is designed to trick you into running it.
Once the Trojan horse infects your computer, it can cause a variety of problems, including stealing data, corrupting files, or downloading additional malware. It can be difficult to detect and remove a Trojan horse, as it often hides itself deep within your computer's system files. Malware can cause serious problems for computer users, including data loss, system crashes, and identity theft.
To protect your computer from malware, you should always keep your antivirus software up to date and avoid downloading or running any programs from unknown sources. You should also be cautious when clicking on links or downloading attachments from emails, as these are common ways that malware can infect your computer.
For more such questions on Trojan horse, click on:
https://brainly.com/question/354438
#SPJ8
Wrong answers will be reported
True or false
This code print the letter “h”
planet = “Earth”
print(planet[5])
Answer:
False
Explanation:
string indexes start at 0 so planet[5] does not exist
Can someone please explain this issue to me..?
I signed into brainly today to start asking and answering questions, but it's not loading new questions. It's loading question from 2 weeks ago all the way back to questions from 2018.. I tried logging out and back in but that still didn't work. And when I reload it's the exact same questions. Can someone help me please??
Answer:
try going to your settings and clear the data of the app,that might help but it if it doesn't, try deleting it and then download it again
How will scan-as-you-go mobile devices and digital wallets impact the retail sector? Which of Porter’s three strategies are evident in the use of scan-as-you-go mobile devices and digital wallets in these examples? What will be the role of smartphones in the future of shopping
Scan-as-you-go mobile devices and digital wallets are having a big impact on the retail sector. These technologies allow shoppers to pay for products more quickly and easily than ever before, making the shopping experience more streamlined and efficient.
The three Porter's strategies - cost leadership, differentiation and focus - are evident in the use of scan-as-you-go mobile devices and digital wallets in retail. Cost leadership is evident in the way mobile devices and digital wallets can reduce overhead costs associated with traditional payment methods, while differentiation is seen in the convenience and personalization that these technologies offer. Lastly, focus is seen in the way that these technologies can be used to target specific customer segments and offer tailored experiences. In the future, smartphones will play an increasingly important role in shopping, as more people are using their phones to make payments and shop online.
Learn more about mobile devices: https://brainly.com/question/29889840
#SPJ11
What percentage of teens say they have witnessed cyberbullying?
50
95
70
35
A Majority of Teens Have Experienced Some Form of Cyberbullying. 59% of U.S. teens have been bullied or harassed online, and a similar share says it's a major problem for people their age
254 × (×) igual 20×()682883993
true or false? a supernode is a user computer selected by the software provider that has enough power to store the index of available music and provide search capabilities.
True. (A supernode is user computer selected by a software provider with sufficient power to store an index of available music and provide search functionality.)
What is a supernode?
In circuit theory, supernodes are theoretical building blocks that can be used to solve circuits. This is done by viewing the voltage source on the wire as a point source voltage relative to the other point voltages found at various nodes in the circuit relative to the ground node assigned zero or negative charge .
How do you recognize supernode?
Supernode are indicated by the dotted area. This is possible because if the total current out of node 2 is zero (0) and the total current out of node 3 is zero (0), the total current out of the combination will be zero.
To know more about Supernode visit here:
https://brainly.com/question/25664639
#SPJ4
(ii)
Give two uses of the Start Menu.
Answer:
used folders, files, settings, and features. It's also where you go to log off from Windows or turn off your computer. One of the most common uses of the Start menu is opening programs installed on your computer. To open a program shown in the left pane of the Start menu, click it
Calculate the formula mass of the molecule from its structure. You are currently in a graphing module. Turn off browse mode or quick nav. formula mass:
The formula mass of a molecule is the sum of the atomic masses of all the atoms in the molecule. To calculate the formula mass, you need to know the chemical formula of the molecule and the atomic masses of its constituent elements.
Here's a step-by-step process to calculate the formula mass:
1. Write down the chemical formula of the molecule. For example, let's consider the molecule water, which has the chemical formula H2O.
2. Determine the atomic masses of the elements in the molecule. You can find these values on the periodic table. In our example, the atomic mass of hydrogen (H) is 1.01 amu (atomic mass units), and the atomic mass of oxygen (O) is 16.00 amu.
3. Multiply the atomic mass of each element by the number of atoms of that element in the molecule. In our example, we have 2 hydrogen atoms and 1 oxygen atom. So, the mass contribution from hydrogen is 2 * 1.01 = 2.02 amu, and the mass contribution from oxygen is 1 * 16.00 = 16.00 amu.
To know more about formula visit:
https://brainly.com/question/20748250
#SPJ11
Which activity is the best example of a negative habit that may result from
heavy computer and Internet usage?
A. Playing web-based games instead using social media
B. Shopping online in order to find a gift for a friend
c. Using apps for driving directions instead of using a paper map
O D. Avoiding local friends in order to play online games
SUBMIT
Answer:
D
Explanation:
Any of these is an example, but the most drastic would be D, Avoiding local friends in order to play online games
when copying word document content to an excel spreadsheet, how many paste options are available from the paste options button?
The Paste Options button in Excel provides users with various options when copying content from a Word document.
When copying content from a Word document to an Excel spreadsheet, the Paste Options button typically provides three paste options:
Keep Source Formatting: This option preserves the formatting of the copied content, including fonts, colors, and styles.
Merge Formatting: This option merges the formatting of the copied content with the existing formatting in the Excel spreadsheet, allowing for consistent styling.
Keep Text Only: This option pastes only the plain text content without any formatting, which can be useful when you want to remove any unwanted formatting from the copied text.
These paste options allow users to choose the most suitable option based on their preferences and the desired outcome in the Excel spreadsheet.
Learn more about spreadsheet click here:
brainly.com/question/11452070
#SPJ11
Each webpage is assigned a(n) ________, an address that identifies the location of the page on the internet.
Each webpage is assigned a uniform resource locator (URL), an address that identifies the location of the page on the internet.
What is assigned to a webpage to identify its location?A URL (Uniform Resource Locator) is known to be a kind of a special form of identifier that is known to be used a lot to be able to find a resource on the Internet. It is known to be a term that is often called the web address.
Note that all webpage is assigned this address that identifies the place of the page on the Internet and a such, Each webpage is assigned a uniform resource locator (URL), an address that identifies the location of the page on the internet.
Learn more about webpage from
https://brainly.com/question/13171394
#SPJ1
during a web site production design phase what might happen? the template is transformed into a working web site. the completed and approved site is birthed to the world. suggestions may be offered to their clients about how to keep the site running smoothly. the wireframe is developed to look like the final product, often in photoshop. it involves specifying the updates and tasks necessary to keep the web site fresh, functioning, and useable.
From the question; the template is transformed into a working web site. Option A
What is website design?The process of designing and organizing different aspects to generate an attractive and useful website is referred to as website design. It includes a website's design, navigation, and user experience. The process of designing and creating a website incorporates both creative and technical elements.
In order to build interesting and useful websites that satisfy the needs of the customer and the target audience, website design is a multidisciplinary subject that combines creativity, user experience, and technological expertise.
Learn more about website design:https://brainly.com/question/27244233
#SPJ4