Answer:
Below is the required JAVA Code:
Explanation:
public static int largestDigit(int n) {
if (n < 0) {
return largestDigit(-1 * n);
} else if (n == 0) {
return 0;
} else {
int digit = n % 10;
int maxDigit = largestDigit(n / 10);
if (digit > maxDigit)
maxDigit = digit;
return maxDigit;
}
}
\color{red}Method\;tested\;in\;a\;complete\;java\;program\;if\;you\;are\;interested.
public class LargestDigitRecursive {
public static int largestDigit(int n) {
if (n < 0) {
return largestDigit(-1 * n);
} else if (n == 0) {
return 0;
} else {
int digit = n % 10;
int maxDigit = largestDigit(n / 10);
if (digit > maxDigit)
maxDigit = digit;
return maxDigit;
}
}
public static void main(String[] args) {
System.out.println(largestDigit(14263203));
System.out.println(largestDigit(845));
System.out.println(largestDigit(52649));
System.out.println(largestDigit(3));
System.out.println(largestDigit(0));
System.out.println(largestDigit(-573026));
System.out.println(largestDigit(-2));
}
}
OUTPUT:
6
8
9
3
0
7
2
Read integers from input and store each integer into a vector until -1 is read. Do not store -1 into the vector. Then, output all values in the vector (except the last value) with the last value in the vector subtracted from each value. Output each value on a new line. Ex: If the input is -46 66 76 9 -1, the output is:
-55
57
67
Answer:
The program in C++ is as follows:
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<int> nums;
int num;
cin>>num;
while(num != -1){
nums.push_back(num);
cin>>num; }
for (auto i = nums.begin(); i != nums.end(); ++i){
cout << *i <<endl; }
return 0;
}
Explanation:
This declares the vector
vector<int> nums;
This declares an integer variable for each input
int num;
This gets the first input
cin>>num;
This loop is repeated until user enters -1
while(num != -1){
Saves user input into the vector
nums.push_back(num);
Get another input from the user
cin>>num; }
The following iteration print the vector elements
for (auto i = nums.begin(); i != nums.end(); ++i){
cout << *i <<endl; }
Every Java statement ends with: *
Period
Colon
Double quote
Semicolon
Answer:
semicolon is the answer
pleeeese help me for these questions
1 Account
2 online
3 access
4 password
5 internet
6 email
which one is exit controllefd loop ?
1.while loop
2. for loop
3. do loop
4. none
Answer:
2 is the ans
Explanation:
bye bye, gonna go to studyy
Saved In order to be used as a primary key, which of these characteristics must an attribute possess with respect to a single instance of the entity? Select all that apply. There must be a maximum of one attribute instance. There must be many instances of the attribute There must be at most one entity instance that each attribute instance describes. There must be at least one instance of the attribute. There must be zero or more instances of the attribute. Question 2 (2 points) True or false: A singular attribute is also known as a unique attribute. True False Question 3 (3 points) Saved Relationship names and types of relationship maxima or minima that each could have are listed below. Match each relationship in the list below to the type of relationship maxima or minima. Instructions: Choose your responses from the drop-down menus below. Response options cannot be used more than once. Minima is One-Zero 1 Person-Assigned Social SecurityNumber 4 Minima is Zero Zero 2 CubicleNumber-Assigned-to- Employee per shift 2 Maxima is One-Many 3. Birthdate-Recorded-for-a Person 1 Maxima is One One 4. Women-Bearing-Children Question 4 (2 points) Saved A ride-sharing app's discount system for riders is configured such that a ride discount is triggered only if at least two RiderlDs book a ride in the same Card at the same time. Which of the following is true of the relationship Ride Discount-is-Applicable?
The relationship minimum is Many-One.
The relationship minimum is Two-One.
The relationship maximum is One-Two.
The relationship minimum is One-Two.
Answer:
Saved In order to be used as a primary key, which of these characteristics must an attribute possess with respect to a single instance of the entity:
There must be a maximum of one attribute instance.
There must be many instances of the attribute.
There must be at most one entity instance that each attribute instance describes.
There must be at least one instance of the attribute.
A singular attribute is also known as a unique attribute. True
Saved Relationship names and types of relationship maxima or minima that each could have are listed below. True
Explanation:
Think about that the C, B and S parameters of a Cache. Think about what happens to compulsory, capacity, conflict misses, if only each of the following parameter changed (the other two are kept the same)?
(i) C is increased (S, B same)
(ii) S is increased (C, B Same)
(iii) B is increased (C, S Same)
Answer:
(i) C is increased (S, B same)
Explanation:
Cache are items which are stored in the computer at a hidden place. These are sometimes unwanted and they may hinder the speed and performance of the device. They exist to bridge speed gap.
computer is an ............. machine because once a task is intitated computer proceeds on its own t ill its completion.
Answer:
I think digital,versatile
computer is an electronic digital versatile machine because once a task is initiated computer proceeds on its own till its completation.
multimedia is an effective tool used in different fields such as business and education true or false
Answer:
True
Explanation:
Multimedia is used in many fields. It is basically the ability to express something in many different ways. This allows you to more easily demonstrate a product, idea, or even a theory. Since this can be through art, video, presentation, text, live, etc. It allows you to find the best format for the specific product or idea that you are trying to present to a group of viewers. That is why it is an effective tool for various fields since it can just as easily help a company sell a product as well as help a teacher express a mathematical concept.
Heinrich Koch is a second-year college student. Last semester his best friend had his laptop stolen. The laptop was an old computer that he planned to replace soon, but the greatest loss was his data: he had not performed a backup and all his data was lost. Heinrich himself does not perform data backups but knows that he needs to do that on a regular basis. He has decided to use an online backup service that will automatically back up his data whenever it changes. Evaluate and compare reviews of online backup services. Consider iDrive, Carbonite, Acronis True Image, BackBlaze, and others you might find in your research. Recommend a service that you consider the best solution for Heinrich. Discuss your reviews and mention speed, security, and features in your recommendation.
Answer:
Acronis True Image is the one I would recommend out of these mentioned online backup services.
Explanation:
The evaluations and reviews of each of the online backup services are as follows:
a. iDrive
For this, we have:
Speed = 60% - fair
Security = 100% - excellent
Privacy = 88% - very good
Features = 95% - excellent
Pricing = 85% - Very good
Because of its various features, pricing, and usability, IDrive reviews suggest that it is a very efficient online backup solution. However, there have been complaints concerning its speed and the fact that there are no monthly plans available.
b. Carbonite
For this, we have:
Speed = 60% - fair
Security = 100% - excellent
Privacy = 87% - very good
Pricing = 85% - very good
File backup and restoration = 75% - good
Carbonite reviews reveal that it is simple to use and provides limitless backup for one device. The main drawback is that it has extremely poor backup speeds.
c. Acronis True Image
This is fast, simple and intuitive
It has complete control over the backup updates, including how and when they occur.
It is not expensive.
Acrnonis True image is a powerful backup storage service. It enables data and file backup and restoration from USB drives.
Many reviewers of Acrnonis True image have stated that they have had no issues with its service, that it is worth purchasing, and that there are no concerns.
d. Backblaze
For this, we have:
Speed = 75% - good
Security = 75% - good
Privacy = 70% - decent
Pricing = 100% - excellent
Support = 95% - excellent
Features = 65% - decent
File back-up and restoration = 70% - decent
Backblaze is one of the most popular internet backup services. This storage service, however, does not allow for ustomization.
Recommendation
Acronis True Image is the one I would recommend out of these mentioned online backup services. This is due to the fact that it delivers a large amount of accurate and high-quality data storage. It is quick, simple and intuitive, which is what most people care about. Furthermore, reviewers have stated that this service is quite effective and that there have been very few issues with it. The other services demonstrate that their services have flaws, such as lack of customization and slowness.
Explain why it is important for you to build proficiency with Microsoft Word.
Answer:
Listing proficiency in Microsoft helps push your resume through applicant tracking systems and into human hands for review. Advanced knowledge of Microsoft Office programs can also increase your earning potential.
Microsoft's skills on your resume can help it get past applicant tracking systems and into human hands for review. Additionally, having more in-depth knowledge of Microsoft Office applications can boost your earning potential.
What is Microsoft skills?Your proficiency and expertise with the Microsoft Office family of software products are collectively referred to as Microsoft Office skills.
Although MS Office has many various programs, employers may frequently assess your proficiency with some of the most widely used ones, such as MS Excel, MS PowerPoint, and MS Word.
The most popular business productivity software globally is Microsoft Office.
Therefore, Microsoft's skills on your resume can help it get past applicant tracking systems and into human hands for review.
Learn more about Microsoft, here:
https://brainly.com/question/28887719
#SPJ2
Examine the following output:
4 22 ms 21 ms 22 ms sttlwa01gr02.bb.ispxy.com [154.11.10.62]
5 39 ms 39 ms 65 ms placa01gr00.bb.ispxy.com [154.11.12.11]
6 39 ms 39 ms 39 ms Rwest.plalca01gr00.bb.ispxy.com [154.11.3.14]
7 40 ms 39 ms 46 ms svl-core-03.inet.ispxy.net [204.171.205.29]
8 75 ms 117 ms 63 ms dia-core-01.inet.ispxy.net [205.171.142.1]
Which command produced this output?
a. tracert
b. ping
c. nslookup
d. netstat
Answer:
a. tracert
Explanation:
Tracert is a computer network diagnostic demand which displays possible routes for internet protocol network. It also measures transit delays of packets across network. The given output is produced by a tracert command.
what is a network computer that processes requests from a client server
Answer:
computer processing unit
computer processing unit is a network computer that processes requests from a client server.
What is a computer processing unit?The main element and "control center" of a computer is the Central Processing Unit (CPU). The CPU, sometimes known as the "central" or "main" processor, is a sophisticated collection of electronic circuitry that manages the device's software and operating system.
A central processing unit, sometimes known as a CPU, is a piece of electronic equipment that executes commands from software, enabling a computer or other device to carry out its functions.
Computers use a brain to process information, much like people do. The brain is the central processing unit for a computer (CPU). The CPU is the component that carries out all of the computer's instructions. It connects with all the other hardware parts of the computer while being on the motherboard.
Thus, computer processing unit.
For more information about computer processing unit, click here:
https://brainly.com/question/29775379
#SPJ6
What is the name given to software that decodes information from a digital file so that a media player can display the file? hard drive plug-in flash player MP3
Answer:
plug-in
Explanation:
A Plug-in is a software that provides additional functionalities to existing programs. The need for them stems from the fact that users might want additional features or functions that were not available in the original program. Digital audio, video, and web browsers use plug-ins to update the already existing programs or to display audio/video through a media file. Plug-ins save the users of the stress of having to wait till a new product with the functionality that they want is produced.
Answer:
B plug-in
Explanation:
Edge2022
the grade point average collected from a random sample of 150 students. assume that the population standard deviation is 0.78. find the margin of error if c = 0.98.
Answer:
[tex]E = 14.81\%[/tex]
Explanation:
Given
[tex]n = 150[/tex]
[tex]\sigma = 0.78[/tex]
[tex]c = 0.98[/tex]
Required
The margin of error (E)
This is calculated as:
[tex]E = z * \frac{\sigma}{\sqrt{n}}[/tex]
When confidence level = 0.98 i.e. 98%
The z score is: 2.326
So, we have:
[tex]E = 2.326 * \frac{0.78}{\sqrt{150}}[/tex]
[tex]E = 2.326 * \frac{0.78}{12.247}[/tex]
[tex]E = \frac{2.326 *0.78}{12.247}[/tex]
[tex]E = \frac{1.81428}{12.247}[/tex]
[tex]E = 0.1481[/tex]
Express as percentage
[tex]E = 14.81\%[/tex]
Given the following tree, use the hill climbing procedure to climb up the tree. Use your suggested solutions to problems if encountered. K is the goal state and numbers written on each node is the estimate of remaining distance to the goal.
What type of editor is used to edit HTML code?What type of editor is used to edit HTML code?
For learning HTML we recommend a simple text editor like Notepad (PC) or TextEdit (Mac).
mark me brainliestt :))
Answer:
If you want to use HTML editor in windows, you can use notepad. And if you want to use HTML editor on your phone than you need to install any editor on your phone.
Explanation:
If you want to use another app than notepad in pc, laptop, mac, OS or Linux, you can download a editor known as Visual Studio Code. If you want to do another language you can also do it in it. You can do all programming languages in it.
Why might you use a navigation form instead of tab pages? The navigation form allows for several levels and sublevels to be collected. The navigation form allows for duplicate records of information to be collected. The navigation form requires all entries to be complete before adding to a database. The navigation form requires report headers and footers to make publication neater.
Answer:
Access includes a Navigation Control that makes it easy to switch between various forms and reports in your database. A navigation form is simply a form that contains a Navigation Control. Navigation forms are a great addition to any desktop database.
Explanation:
yes
Answer:
answer c
Explanation:
correct answer on edge
The following pseudocode describes how a widget company computes the price of an order from the total price and the number of the widgets that were ordered. Read the number of widgets. Multiple the number of widgets by the price per widget of 9.99. Compute the tax (5.5 percent of the total price). Compute the shipping charge (.40 per widget). The price of the order is the sum of the total widget price, the tax, and the shipping charge. Print the price of the order
Answer:
The program in Python is as follows:
widget = int(input("Widgets: "))
price = widget * 9.9
tax = price * 0.55
ship = price * 0.40
totalprice = price + tax + ship
print("Total Price: $",totalprice)
Explanation:
The question is incomplete, as what is required is not stated.
However, I will write convert the pseudocode to a programming language (in Python)
Get the number of widgets
widget = int(input("Widgets: "))
Calculate price
price = widget * 9.9
Calculate the tax
tax = price * 0.55
Calculate the shipping price
ship = price * 0.40
Calculate the total price
totalprice = price + tax + ship
Print the calculated total price
print("Total Price: $",totalprice)
How does a distributed operating system work?
Answer:
A distributed operating system is system software over a collection of independent, networked, communicating, and physically separate computational nodes. They handle jobs which are serviced by multiple CPUs. Each individual node holds a specific software subset of the global aggregate operating system.
These systems run on a server and provide the capability to manage data, users, groups, security, applications, and other networking functions.
plz mark it as brainliest
Answer:
Explanation:A distributed operating system is system software over a collection of independent, networked, communicating, and physically separate computational nodes. They handle jobs which are serviced by multiple CPUs. Each individual node holds a specific software subset of the global aggregate operating system.
Functions should contain only the code that performs a single task.
O True
O False
Answer:
false
Explanation:
function should contain more codes
While saving a document to her hard drive, Connie's computer screen suddenly changed to display an error message on a blue background. The error code indicated that there was a problem with her computer's RAM. Connie's computer is affected by a(n) __________.
Answer:
The right answer is "Hardware crash".
Explanation:
According to the runtime error message, this same RAM on your machine was problematic. This excludes file interoperability or compliance problems as well as program error possibilities.Assuming implementation performance problems exist, the timeframe that would save the information would be typically longer, but there's still a lower possibility that the adequacy and effectiveness color will become blue but instead demonstrate warning would appear.Thus the above is the right solution.
In this project you will write a set of instructions (algorithm). The two grids below have colored boxes in different
locations. You will create instructions to move the colored boxes in grid one to their final location in grid two. Use the
example to help you. The algorithm that you will write should be in everyday language
(no pseudocode or programming language). Write your instructions at the bottom of the
page.
Example: 1. Move
the orange box 2
spaces to the right.
2. Move the green
box one space
down. 3. Move the
green box two
spaces to the left.
Write your instructions. Review the rubric to check your final work.
Rules: All 6 colors (red, green, yellow, pink, blue, purple) must be move to their new location on the grid. Block spaces are
barriers. You cannot move through them or on them – you must move around them
Answer:
Explanation:
Pink: Down 5 then left 2.
Yellow: Left 3 and down 2.
Green: Right 7, down 4 and left 1.
Purple: Up 6 and left 9.
Red: Left 7, down 5 and left 1.
You can do the last one, blue :)
Answer:
Explanation:
u=up, d=down, r=right, l=left
yellow: l3d2
pink: d5l2
green: r7d4l1
purple: u6l9
red: l7d5l1
blue: r2u7l5
Viết chương trình kiểm tra số nguyên dương N có phải là số nguyên tố không?
Questions to ask people on how corona has affected the religion sectors
Answer:
bcoz of corona all churches and temples are closed and pilgrimage are cancelled
Given two regular expressions r1 and r2, construct a decision procedure to determine whether the language of r1 is contained in the language r2; that is, the language of r1 is a subset of the language of r2.
Answer:
Test if L(M1-2) is empty.
Construct FA M2-1 from M1 and M2 which recognizes the language L(>M2) - L(>M1).
COMMENT: note we use the algorithm that is instrumental in proving that regular languages are closed with respect to the set difference operator.
Test if L(M2-1) is empty.
Answer yes if and only if both answers were yes.
Explanation:
An algorithm must be guaranteed to halt after a finite number of steps.
Each step of the algorithm must be well specified (deterministic rather than non-deterministic).
Three basic problems:
Given an FA M and an input x, does M accept x?
Is x in L(M)
Given an FA M, is there a string that it accepts?
Is L(M) the empty set?
Given an FA M, is L(M) finite?
Algorithm for determining if M accepts x.
Simply execute M on x.
Output yes if we end up at an accepting state.
This algorithm clearly halts after a finite number of steps, and it is well specified.
This algorithm is also clearly correct.
Testing if L(M) is empty.
Incorrect "Algorithm"
Simulate M on all strings x.
Output yes if and only if all strings are rejected.
The "algorithm" is well specified, and it is also clearly correct.
However, this is not an algorithm because there are an infinite number of strings to simulate M on, and thus it is not guaranteed to halt in a finite amount of time.
COMMENT: Note we use the algorithm for the first problem as a subroutine; you must think in this fashion to solve the problems we will ask.
Correct Algorithm
Simulate M on all strings of length between 0 and n-1 where M has n states.
Output no if and only if all strings are rejected.
Otherwise output yes.
This algorithm clearly halts after a finite number of steps, and it is well specified.
The correctness of the algorithm follows from the fact that if M accepts any strings, it must accept one of length at most n-1.
Suppose this is not true; that is, L(M) is not empty but the shortest string accepted by M has a length of at least n.
Let x be the shortest string accepted by M where |x| > n-1.
Using the Pumping Lemma, we know that there must be a "loop" in x which can be pumped 0 times to create a shorter string in L.
This is a contradiction and the result follows.
COMMENT: There are more efficient algorithms, but we won't get into that.
Testing if L(M) is finite
Incorrect "Algorithm"
Simulate M on all strings x.
Output yes if and only if there are a finite number of yes answers.
This "algorithm" is well specified and correct.
However, this is not an algorithm because there are an infinite number of strings to simulate M on, and thus it is not guaranteed to halt in a finite amount of time.
COMMENT: Note we again use the algorithm for the first problem as a subroutine.
Correct Algorithm
Simulate M on all strings of length between n and 2n-1 where M has n states.
Output yes if and only if no string is accepted.
Otherwise output no.
This algorithm clearly halts after a finite number of steps, and it is well specified.
The correctness of the algorithm follows from the fact that if M accepts an infinite number of strings, it must accept one of length between n and 2n-1.
This builds on the idea that if M accepts an infinite number of strings, there must be a "loop" that can be pumped.
This loop must have length at most n.
When we pump it 0 times, we have a string of length less than n.
When we pump it once, we increase the length of the string by at most n so we cannot exceed 2n-1. The problem is we might not exceed n-1 yet.
The key is we can keep pumping it and at some point, its length must exceed n-1, and in the step it does, it cannot jump past 2n-1 since the size of the loop is at most n.
This proof is not totally correct, but it captures the key idea.
COMMENT: There again are more efficient algorithms, but we won't get into that.
Other problems we can solve using these basic algorithms (and other algorithms we've seen earlier this chapter) as subroutines.
COMMENT: many of these algorithms depend on your understanding of basic set operations such as set complement, set difference, set union, etc.
Given a regular expression r, is Lr finite?
Convert r to an equivalent FA M.
COMMENT: note we use the two algorithms for converting a regular expression to an NFA and then an NFA to an FA.
Test if L(M) is finite.
Output the answer to the above test.
Given two FAs M1 and M2, is L(M1) = L(M2)?
Construct FA M1-2 from M1 and M2 which recognizes the language L(>M1) - L(>M2).
COMMENT: note we use the algorithm that is instrumental in proving that regular languages are closed with respect to the set difference operator.
Test if L(M1-2) is empty.
Construct FA M2-1 from M1 and M2 which recognizes the language L(>M2) - L(>M1).
COMMENT: note we use the algorithm that is instrumental in proving that regular languages are closed with respect to the set difference operator.
Test if L(M2-1) is empty.
Answer yes if and only if both answers were yes.
After reading all L02 content pages in Lesson 02: Inheritance and Interfaces, you will complete this assignment according to the information below.Do not use the scanner class or any other user input request. You application should be self-contained and run without user input.Assignment ObjectivesPractice on implementing interfaces in JavaFootballPlayer will implement the interface TableMemberOverriding methodswhen FootballPlayer implements TableMember, FootballPlayer will have to write the real Java code for all the interface abstract methodsDeliverablesA zipped Java project according to the How to submit Labs and Assignments guide.O.O. Requirements (these items will be part of your grade)One class, one file. Don't create multiple classes in the same .java fileDon't use static variables and methodsEncapsulation: make sure you protect your class variables and provide access to them through get and set methodsAll the classes are required to have a constructor that receives all the attributes as parameters and update the attributes accordinglyAll the classes are required to have an "empty" constructor that receives no parameters but updates all the attributes as neededFollow Horstmann's Java Language Coding GuidelinesOrganized in packages (MVC - Model - View Controller)Contents
Solution :
App.java:
import Controller.Controller;
import Model.Model;
import View.View;
public class App
{
public static void main(String[] args) // Main method
{
Model model = new Model(); // Creates model object.
View view = new View(); // Creates view object.
Controller controller = new Controller(view, model); // Creates controller object that accepts view and model objects.
}
}
[tex]\text{Controller.java:}[/tex]
package Controller;
[tex]\text{impor}t \text{ Model.Model;}[/tex]
import View.View;
[tex]\text{public class Controller}[/tex]
{
Model model; // Model object
View view; // View object
public Controller(View v, Model m) // Method that imports both model and view classes as objects.
{
model = m;
view = v;
//view.basicDisplay(model.getData()); // basicDisplay method from View class prints FootballPlayer objects as Strings from Model class.
view.basicDisplay(model.getMembers().get(1).getAttributeName(3));
view.basicDisplay(model.getMembers().get(1).getAttribute(3));
view.basicDisplay(model.getMembers().get(1).getAttributeNames());
view.basicDisplay(model.getMembers().get(1).getAttributes());
view.basicDisplay("size of names=" + model.getMembers().get(1).getAttributeNames().size());
view.basicDisplay("size of attributes=" + model.getMembers().get(1).getAttributes().size());
}
}
FootballPlayer.java:
package Model;
import java.util.ArrayList;
public class FootballPlayer extends Person implements TableMember { // Used "extends" keyword to inherit attributes from superclass Person, while using "implements" to implement methods from TableMember interface.
private int number; // Creating private attribute for int number.
private String position; // Creating private attribute for String position.
public FootballPlayer(String name, int feet, int inches, int weight, String hometown, String highSchool, int number, String position) // Full parameter constructor for FootballPlayer object (using "super" keyword to incorporate attributes from superclass).
{
super(name, feet, inches, weight, hometown, highSchool); // Used super keyword to include attributes from superclass.
this.number = number; // Value assigned from getNumber method to private number instance variable for FootballPlayer object.
this.position = position; // Value assigned from getPosition method to private position instance variable for FootballPlayer object.
}
public FootballPlayer() // No parameter constructor for FootballPlayer object.
{
this.number = 0; // Default value assigned to private number instance variable under no parameter constructor for FootballPlayer object.
this.position = "N/A"; // Default value assigned to private position instance variable under no parameter constructor for FootballPlayer object.
}
Override
public String getAttribute(int n) // getAttribute method that is implemented from interface.
{
switch (n) { // Switch statement for each attribute from each FootballPlayer object. Including two local attributes, denoted by this. While the others are denoted by "super".
case 0:
return String.valueOf(this.number); // Use of the dot operator allowed me to discover String.valueOf method to output int attributes as a string.
case 1:
return this.position;
case 2:
return super.getName();
case 3:
return super.getHeight().toString();
case 4:
return String.valueOf(super.getWeight());
case 5:
return super.getHometown();
case 6:
return super.getHighSchool();
default:
return ("invalid input parameter");
}
}
Override
public ArrayList<String> getAttributes() // getAttributes ArrayList method that is implemented from interface.
{
ArrayList<String> getAttributes = new ArrayList<>();
for(int i = 0; i <= 6; i++){ // For loop to add each attribute to the getAttributes ArrayList from getAttributes method.
getAttributes.add(getAttribute(i));
}
return getAttributes;
}
Override
public String getAttributeName(int n) // getAttributeName method implemented from interface.
{
switch (n) { // Switch statement for the name of each attribute from each FootballPlayer object.
case 0:
return "number";
case 1:
return "position";
case 2:
return "name";
case 3:
return "height";
case 4:
return "weight";
case 5:
return "hometown";
case 6:
return "highSchool";
default:
return ("invalid input parameter");
}
}
Write a program that lets the user enter the total rainfall for each of 12 months into an array of doubles. The program should calculate and display the total rainfall for the year and the average monthly rainfall. Use bubble sort and sort the months with the lowest to highest rain amounts. Use the binary search and search for a specific rain amount. If the rain amount is found, display a message showing which month had that rain amount. Input Validation: Do not accept negative numbers for monthly rainfall figures.
Answer:
Program approach:-
Using the header file.Using the standard namespace I/O.Define the main function.Check whether entered the value is negative.Find the middle position of the array.Display message if value not found.Returning the value.Explanation:
Program:-
//required headers
#include <stdio.h>
#include<iostream>
using namespace std;
//main function
int main()
{ double rain[12], temp_rain[12], sum=0, avg=0, temp;
int month=0, i, j, n=12, low=0, mid=0, high=12, x, found=0;
char month_name[][12]={"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"};
//store input values to arrays rain and temp_rain
while(month<n)
{ cout<<"Enter the total rainfall for month "<<month+1<<" :";
cin>>temp;
//check whether the entered value is negative
if(temp<0)
{ cout<<"Enter a non negative value"<<endl;
}
else
{ rain[month]=temp;
temp_rain[month]=temp;
//total sum is found out and stored to sum
sum+=temp;
month++;
}
}
//find average rainfall
avg=sum/n;
//display total and average rainfall for the year
cout<<"Total rainfall for the year: "<<sum<<endl;
cout<<"Average rainfall for the year: "<<avg<<endl;
//perform bubble sort on temp_rain array
for(i=0; i<n-1; i++)
{ for (j=0; j<n-i-1; j++)
{ if (temp_rain[j]>temp_rain[j+1])
{
temp=rain[j];
temp_rain[j]=temp_rain[j+1];
temp_rain[j+1]=temp;
}
}
}
//get search value and store it to x
cout<<"Enter the value to search for a specific rain amount: ";
cin>>x;
//perform binary search on temp_rain array
while (low<=high)
{
//find the middle position of the array
int mid=(low+high)/2;
//if a match is found, set found=1
if(x==temp_rain[mid])
{ found=1;
break;
}
//ignore right half if search item is less than the middle value of the array
else if(x<temp_rain[mid])
high=mid-1;
//ignore left half if search item is higher than the middle value of the array
else
low=mid+1;
}
//if a match is found, then display the month for the found value
if(found==1)
{
for(i=0; i<n; i++)
{ if(x==rain[i])
cout<<"Found matching rainfall for this month: "<<month_name[i];
}
}
//display message if value not found
else
cout<<"Value not found.";
return 0;
}
Give two examples of html structure
Answer:
semantic information that tells a browser how to display a page and mark up the content within a document
How are dates and times stored by Excel?
Answer:
Regardless of how you have formatted a cell to display a date or time, Excel always internally stores dates And times the same way. Excel stores dates and times as a number representing the number of days since 1900-Jan-0, plus a fractional portion of a 24 hour day: ddddd. tttttt
Explanation:
mark me as BRAINLIEST
follow me
carry on learning
100 %sure
Design traffic lights at an intersection of a city. North and South (up and down) are going to be a main highway, East and West (right and left) will be a smaller cross street. There will be no turn signals and no cross walks. You only need to build/code one set of lights for each street (one set of green, yellow, and red for the highway, and another set for the cross street). You do not need to build actual traffic lights or an intersection.
Answer:
Explanation:
The following code is written in Java. In order to code this efficiently, I created a class for the trafficLights. The class contains the currentLight, and the streetType as variables and contains a constructore, getter and setter methods, and a method to turn to the next light in the sequence. Then I created 4 objects of TrafficLights for the highways and the streets.
class Brainly {
public static void main(String[] args) {
TrafficLights highwaySouth = new TrafficLights("Highway", "green");
TrafficLights highwayNorth = new TrafficLights("Highway", "green");
TrafficLights streetEast = new TrafficLights("Street", "yellow");
TrafficLights streetWest = new TrafficLights("Street", "red");
}
}
class TrafficLights {
String streetType, currentLight;
public TrafficLights(String streetType, String currentLight) {
this.streetType = streetType;
this.currentLight = currentLight;
}
public void nextLight() {
if (this.currentLight == "green") {
this.currentLight = "yellow";
} else if (this.currentLight == "yellow") {
this.currentLight = "red";
} else {
this.currentLight = "green";
}
}
public String getStreetType() {
return streetType;
}
public void setStreetType(String streetType) {
this.streetType = streetType;
}
public String getCurrentLight() {
return currentLight;
}
public void setCurrentLight(String currentLight) {
this.currentLight = currentLight;
}
}