Please solve this in Java.
Assume we have already defined a variable of type int called num with the following line of code:
int num = ???; // 'num' can have any int value
TASK: Print a Triforce composed of 3 centered triangles created with num asterisks (*) on the bottom row, num - 2 asterisks on the next bottom row, ..., and 1 asterisk on the top row, and such that the triangles are surrounded by hyphens (-). You can assume that num is odd and is at least 3.
EXAMPLE: If num is 5, the resulting Triforce would be the following:
-----*----- ----***---- ---*****--- --*-----*-- -***---***- *****-*****
Sample Input:
5
Sample Output:
-----*----- ----***---- ---*****--- --*-----*-- -***---***- *****-*****
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int num = 5;
int cols = 2*num+1;
for(int i=1;i<=num;i+=2){
int dash = num-i+1;
for(int j=0;j<dash;j++){
System.out.print("-");
}
for(int j=0;j<cols-2*dash;j++){
System.out.print("*");
}
for(int j=0;j<dash;j++){
System.out.print("-");
}
System.out.println();
}
for(int i=1;i<=num;i+=2){
int dash = (num-i+1)/2;
for(int j=0;j<dash;j++){
System.out.print("-");
}
for(int j=0;j<i;j++) {
System.out.print("*");
}
for(int j=0;j<dash;j++){
System.out.print("-");
}
System.out.print("-");
for(int j=0;j<dash;j++){
System.out.print("-");
}
for(int j=0;j<i;j++) {
System.out.print("*");
}
for(int j=0;j<dash;j++){
System.out.print("-");
}
System.out.println();
}
}
}
OUTPUT :

Please solve this in Java. Assume we have already defined a variable of type int called...
*JAVA* Assume we already have an ArrayList of Integers called list. Write code that will add 1 to each element of the list. For example, if the list originally contained 2, 4, -3, then it should contain 3, 5, -2 after the lines of code execute. Just write the necessary lines of code (not a whole method or program). Assume we already created the ArrayList and filled it with Integers.
please use JAVA to solve it.
Checkers is played on an N XN checker board, with one side playing the black pieces and the ofther side playing the white pieces. Glven a board size N and the positions of the black and white checkers, create a program to print out the resulting checker board. INPUT Row, Column Integer N denoting the size of the board Integer B denoting the number of black pieces to be placed on the board, followed...
please answer correctly.
Language/Type Java Inheritance polymorphism Assume that the following classes have been defined: public class George extends Elaine ( public void method1() { print("George 1 "); public class Jerry { public void method10) { print("Jerry 1 "); public void method20 { print("Jerry 2 "); public String toString() { return "Jerry": public class Elaine extends Kramer public String toString() { return "Elaine " + super.toString(); public class Kramer extends Jerry public void method1() { super.method1(); print ("Kramer 1"); public...
Solve in Java and Python public static int feedCows(int[] cows, int k) You are a farmer with a row of cows that need feeding and an unlimited supply of food at the beginning of the row of cows. The cows are represented as an array, cows, where cows[i] is the non-negative amount of cups of food that cow needs. Capacity, k, is the amount of cups of food you can hold in your bucket. You have to feed all the...
This is the contents of Lab11.java
import java.util.Scanner;
import java.io.*;
public class Lab11
{
public static void main(String args[]) throws IOException {
Scanner inFile = new Scanner(new File(args[0]));
Scanner keyboard = new Scanner(System.in);
TwoDArray array = new TwoDArray(inFile);
inFile.close();
int numRows = array.getNumRows();
int numCols = array.getNumCols();
int choice;
do {
System.out.println();
System.out.println("\t1. Find the number of rows in the 2D
array");
System.out.println("\t2. Find the number of columns in the 2D
array");
System.out.println("\t3. Find the sum of elements...
Must be done in Java.
PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS
WELL.
Provide the rest of the code with full comments and
explanation and with proper indentation.
Use simple methods for better
understanding.
Must compile.
At the end show the exact Output that's shown in the
Problem 2.
CODE PROVIDED FOR PROBLEM 1:
import java.util.Scanner;
public class Problem1
{
public static void main( String [] args )
{
//N denoting the size of the
board
int...
Must be done in Java.
PROBLEM 1 INFORMATION AND THE CODE PROVIDED WITH IT AS
WELL.
Provide the rest of the code with full comments and
explanation and with proper indentation.
Use simple methods for better
understanding.
Must compile.
At the end, show the exact Output that's shown in
Problem 2.
CODE PROVIDED FOR PROBLEM 1:
import java.util.Scanner;
public class Problem1
{
public static void main( String [] args )
{
//N denoting the size of the
board
int n;
...
please answer the question in
java. Thank you!
6:02 PM Wed Jan 29 83% stepik.org stepik 2222222222222222 NH Nathanael UCSD CSE 11 Course progress: 63/92 We have declared a method called addSorted with one ArrayList<Integer> parameter sortedNums and one int parameter newNum. You can assume sortedNums is on-empty and is already sorted in ascending (i.e., increasing) order. TASK: Fill in the body of the addSorted method such that it will add newNum to sortedNums while maintaining sorted order. 1 Week...
Must be done in Java.
PROBLEM 2 INFORMATION AND THE CODE PROVIDED WITH IT AS
WELL.
PROBLEM 1 INFORMATION IF YOU NEED IT AS
WELL:
Provide the rest of the code with full comments and
explanation and with proper indentation.
Use simple methods for better
understanding.
Must compile.
At the end, show the exact Output that's shown in
Problem3.
CODE PROVIDED FOR PROBLEM 2:
import java.util.Scanner;
public class Problem2
{
public static void main( String [] args )
{
//N...
IN C++ PLEASE -------Add code to sort the bowlers. You have to sort their parallel data also. Print the sorted bowlers and all their info . You can use a bubble sort or a shell sort. Make sure to adjust your code depending on whether or not you put data starting in row zero or row one. Sort by Average across, lowest to highest. The highest average should then be on the last row.. When you sort the average, you...