Write a function named "reverse" that takes as its arguments the following:
(1) an array of floating point values;
(2) an integer that tells how many floating point values are in the array.
The function must reverse the order of the values in the array. Thus, for
example, if the array that's passed to
the function looks like this:
0 1 2 3 4
5.8 | 2.6 | 9.0 | 3.4 | 7.1
then when the function returns, the array will have been modified so that it
looks like this:
0 1 2 3 4
7.1 | 3.4 | 9.0 | 2.6 | 5.8
The function should not return any value.
Write a Java driven application that performs the following tasks:
1. Allow the user to decide on the length of an array that will be created at run time.
2. Enter integer elements into such an array
3. Sort the elements in ascending order (DO NOT USE bubble sort)
4. Search for a user specified element in the array and return the number of times
the searched key is observed (DO NOT USE linear search)
The students’ IDs and test answers are
stored in a file. The first entry in the file contains answers to the test in the form:
TFFTFFTTTTFFTFTFTFTT
Every other entry in the file is the student ID, followed by a blank, fol- lowed by the student’s responses. For example,
the entry:
ABC54301 TFTFTFTT TFTFTFFTTFT
indicates that the student ID is ABC54301 and the answer to question 1 is True, the answer to question 2 is False, and
so on. This student did not answer question 9. The exam has 20 questions, and the class has more than 150 students.
Each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero
points.
Write a program that processes the test data. The output should be the student’s ID, followed by the answers, followed
by the test score, followed by the test grade. Assume the following grade scale: 90%–100%, A; 80%–89.99%, B; 70%–
79.99%, C; 60%–69.99%, D; and 0%–59.99%, F.
you are working as a freelancer. A company approached you and asked to create an algorithm for username validation. The company said that the username is string S .You have to determine of the username is valid according to the following rules.
1.The length of the username should be between 4 and 25 character (inclusive).
2.Valid username must start with a letter.
3 Valid username can only contain letters, numbers, and underscores characters.
4 Valid username cannot ends with the underscore character and also doesn't accept the special characters.
INPUT: The first line contains an integer T representing the number of test cases.
The first line of each test cases input contains a string.
OUTPUT: Each test case gives a Boolean value as output(true or false)
sample Input:
3
Google_123
google@123
sampleOutput
true
true
false
sample input 2
HelloPython
#Coder
CoderIt
sampleoutput 2
true
false
true
a runner runs 14 kılometers in 45 minutes and 30 sec-
onds. Write a program that displays the average speed in miles per hour. (Note that
1 mile is 1.6 kilometers.)
Part 1:
You will use the Random function to write the following JAVA program. Write a program named Dice4.java.
The minimum number generated by the two dice is 2 and maximum number is 12. Throw the dice and if the number generated is less than or equal to 3 than you lose and if it is greater or equal to 9 than you win and if you get a number between 4-8 then it is a tie. You will make use of Random function and a selection structure (if/else) to write the code.
Save the document as Dice4.java.
Write a program which consists of a single class called BuyStuff that asks the user for two amounts, adds them, calculates tax at 15%, shows the result to the user, and asks for money. It then compares if the person gave enough money. If so, it displays the amount of change to return otherwise it displays a message asking for more money
Create your own class named BankAccount that illustrates the use of encapsulation as shown above.
Make sure to include at least one setter and one getter for the class. Add variables and methods
related to a BankAccount class as many as you can.
Write a program that requests the user for a year (you can assume the year will always be at
least 2000), the population of Brazil in that year (in terms of millions of people) and the annual
population growth rate (always as a real number in the range 0 – 1), and then uses the two
methods written above to determine and display the year in which Brazil’s population first
exceeded/exceeds 18
a) Write a method PopulationTotal that accepts 2 positive values, namely the current
population (in millions, e.g. a value of 1.5 means 1.5 million people) and the growth rate (e.g.
0.14 means 14%). The method determines and returns the total population based on the current
population and growth rate. For example, if the current population for a country is 1.165 million
people, and the annual population growth rate is 10%, then the total population is 1.2815 million
people after 1 year.
b) Write a method Over180Million that accepts a positive value representing the population (in
millions). The method determines whether the population is over 180 million people, and returns
a value of true if this is so, otherwise returns a value of false.