Answer:
import java.util.Scanner;
public class num4 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int size;
do{
System.out.println("Enter size of triangle");
size = in.nextInt();
}while(size<=1 || size>=50);
for(int i = 1; i <= size; ++i) {
for(int j = 1; j <= i; ++j) {
System.out.print("* ");
}
System.out.println();
}
System.out.println();
//Second triangle bottom up
for(int i = size; i >= 1; --i) {
for(int j = 1; j <= i-1; ++j) {
System.out.print("* ");
}
System.out.println();
}
}
}
Explanation:
- Use Scanner class to receive user value for size
- Use a do......while loop to ensure user entered a valid range (1-50)
- Use nested loops to print the first triangle from i = 1
- Print also the second triangle from i = size downwards
Answer:
Explanation:
Developing in the cloud enables users to get their applications to market quickly. Hardware failures do not result in data loss because of networked backups. Cloud computing uses remote resources, saving organizations the cost of servers and other equipment.
hope it helps.
Answer:
// name of the package
package stringlength;
// Scanner is imported but it is not needed
// So it is commented
// import java.util.Scanner;
// The class name StringLength is defined
public class StringLength {
// main method to signify the beginning of program execution
public static void main(String[] args) {
// if-statement to check if argument is supplied to
// command line
if(args.length > -1) {
// the first argument is read and assigned to input
String input = args[0];
int length = input.length(); // using length() method in String class
System.out.println("Your string has a length of "+length+" characters.");
} else {
System.out.println("Please enter your string argument in quote");
}
}
}
Explanation:
The code works fine with little modification and comments. The user should supply the string arguments in quote. The quote must surround the strings because our logic read the first argument passed to the command line. Inserting a string with space between them will provide a wrong output.
A sample image is attached.
Answer: Yes.
Explanation: Most good businesses have to deal with conflict, whether it be law suits, unhappy customers, even occasional bad reviews could be considered conflict. although better businesses usually have less conflict than bad businesses