1. Write a program in Java to display a right-angled triangle pattern with numbers, as shown below.
Expected Output :
1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910
ball is thrown vertically upwards with an initial velocity of 30 m/s.
Using a time step of 0.02 s up to 6.20 s, write a matlab code to give a plot of the vertical distance versus
time for this ball.
Hint ; Motion under gravity is described by the equation : 𝑣𝑦 = 𝑣𝑜𝑦𝑡 +
1
2
𝑔𝑡
2
and gravitational acceleration 𝑔 is here taken as negative.
Then use your code to answer the following questions:
(i) To what maximum height does the ball rise?
(ii) What is the index of time at maximum height?
(iii) How long does it take the ball to ascend to maximum height?
(iv) How long does it take the ball to hit the ground?
(v) What happens to the ball if the sign for gravitational acceleration is taken as positive?
Math Quiz
Riya took part in a maths quiz competition. To win the prize money she has to solve a tricky question at the end.For a given list of integers, write a program where all the integers in a given index range to be added.
She will be given M multiple ranges, where she should print the sum of numbers for each corresponding range.
Note: The limits in the range are both inclusive.
Input
The first line f input is space-separated integers.
The second line of input is a positive integer M denoting the number of index ranges.
The next M lines contain two space-separated integers of the range.
Output
The output should be M lines.
Each line contains an integer that represents the sum for the corresponding ranges.
Sample Input1
1 3 4 5 6
5
3 5
Sample Output1
12
Maximum Number of Books
There are multiple (T) bookstores in the area.Each shopkeeper has a list of B integers that represents the cost of each book.You have different pocket money(P) for each bookstore.Write a program to calculate the maximum number of books you can buy in each store with the corresponding pocket money.
Explanation
Given P = 600 and B = [120, 140, 110, 180, 120, 110] with a pocket money of 600, we can buy the books at index 0,1,2,4,5 , whose sum is 120+140+110+120+110 is equal to P.
Given P = 300 and B = [120 110 1300 130] with a pocket money of 300, we can buy the books at index 0,1 whose sum is 120 + 110 and is less than P.
Given P = 100 and B = [220 1000 500 2000] with pocket money of 100, we can't buy any book. So the output should be Retry.
Sample Input1
3
6 100
20 40 10 80 20 10
4 70
20 10 300 30
4 200
220 1000 500 2000
Sample Output1
5
3
Sample Input2
2
8 250
2070 1350 365 2750 30 20 140 240
4 500
1070 2893 2200 39
Sample Output2
3
1
Write an application for a furniture company; the program determines the price of a table. Ask the user to choose 1 for pine, 2 for oak, or 3 for mahogany. The output is the name of the wood chosen as well as the price of the table. Pine tables cost R 100, oak tables cost R 225, and mahogany tables cost R 310. If the user entered an invalid wood code, set the price to 0 and allow the user to select an option up to 3 times . Save the file as Furniture.java. Marks allocation 1. Presentation of a menu - 10 Select an option 1. for pine 2. for oak 3. for mahogany 2. use of a loop - 10 3. Use of an if statement/ switch - 10 4. correct output -10
Repeated Numbers
Eren wants to decode a number.After lots of trial and error, he finally figured out that the number is a count of repeated single-digit integers.
Write a program to help Eren print the decoded number given a string of integers N.
Input
The first line contains a string of integers N.
Output
The output contains a single integer representing count of repeated numbers in the input.
Explanation
For N = 212311 ,
1 and 2 are repeated.Therefore, the output is 2.
Sample Input1
212311
Sample Output1
2
Sample Input2
111
Sample Output2
1
This program will write a series of letters, starting with 'A', to an external file (letters.txt). The user will decide how many letters in total get saved to the file.
** IMPORTANT: The test cases will evaluate your code against .txt files that I uploaded. You do NOT have to upload your own txt files.
Input:
Including 'A', how many total letters would you like to store? [user types: 26]
Output (in the file, not in the console window)
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
This program will read a bunch of numbers from an external file (numbers.txt) and calculate their total and average. In addition, the total will be multiplied by an integer that is supplied by the user.
** IMPORTANT: The numbers are included in your starter code as a separate file (numbers.txt). Don't touch that file! All of your code should be placed in code.cpp, as usual. **
Input:
After all numbers are read, what number would you like to multiply the total by? [user types: 2]
Output:
Total = 1717
Average = 50.5
Total * 2 = 3434
Create an HTML & CSS quick-reference guide that covers all of the tags we've covered so far (and a few extras) with a description of how to use them and code examples.
Create a new index.html file and include the following: