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.
The toll program illustrates the use of conditional statements;
As a general rule, conditional statements are used to make decisions
<h3>The
toll program</h3>
The toll program written in Python where conditional statements are used to make several decisions is as follows:
def calc_toll(hour, morning, weekend):
toll_fee = 0
if weekend == False:
if morning == True:
if hour < 7:
toll_fee+=1.15
elif hour < 10:
toll_fee+=2.95
elif hour <= 12:
toll_fee+=1.90
else:
if hour < 3:
toll_fee+=1.90
elif hour < 8:
toll_fee+=3.95
elif hour >= 8:
toll_fee+=1.40
else:
if morning == True:
if hour < 7:
toll_fee+=1.05
elif hour <= 12:
toll_fee+=2.15
else:
if hour < 8:
toll_fee+=2.15
elif hour >= 8:
toll_fee+=1.10
return toll_fee
Read more about conditional statements at:
brainly.com/question/24833629
#SPJ1
I think is the number keys I not sure hope it help
It says insert image I think. Or there’s a button that looks like a picture