I think it might be short range and long-term
Answer:
- public class Main {
- public static void main(String[] args) {
- System.out.println(firstDigit(1729));
- System.out.println(lastDigit(1729));
- System.out.println(digits(1729));
- }
-
- public static int firstDigit(int n){
- String n_str = Integer.toString(n);
- char firstChar = n_str.charAt(0);
- String firstDigit = Character.toString(firstChar);
- return Integer.parseInt(firstDigit);
- }
-
- public static int lastDigit(int n){
- String n_str = Integer.toString(n);
- char lastChar = n_str.charAt(n_str.length() - 1);
- String lastDigit = Character.toString(lastChar);
- return Integer.parseInt(lastDigit);
- }
-
- public static int digits(int n){
- String n_str = Integer.toString(n);
- return n_str.length();
- }
- }
Explanation:
Firstly we create a method firstDigit that will return the first digit of the input number (Line 8 - 13). This method will convert the input number, n, to string using Integer toString method (Line 9) and assign it to n_stry variable. Next, use charAt method with 0 index to get the first character from n_str and assign it to firstChar variable (Line 10). Next, use Character toString method to convert the firstChar to string type (Line 11) because the parseInt method which is used in Line 12 will only work on String type but not char type. The function return the firstDigit with integer type (Line 12). The parseInt method has converted the string type firstDigit to integer.
The logical steps defined for lastDigit method are similar to firstDigit except that we need to use .length() method to get the length of the digit string and calculate the last index to get the last digit (Line 17).
The digits method (Line 22 -25) will convert the input number to string and then use .length() method to return the length of the number string which is equivalent of number of digit as output.
Answer:
1) SQL Server
SELECT Top 5 concate(first name,' ',last name) AS Full name, Current age AS Age, state AS Address, Phone number AS Contact number from actor ORDERBY Current age DSC ;
2) MySQL
SELECT concate(first name,' ',last name) AS Full name, Current age AS Age, state AS Address, Phone number AS Contact number from actor ORDERBY Current age DSC limit 5;
Explanation:
There two queries first having syntax works fine in SQL server and later with MySQL. All bold faced words are sql keywords. I assumed the tablename is actor as table name is not given if table name is any other replace actor with that name.
Answer:
Spam
Explanation:
Spam is unsolicited bulk messages, that is, messages sent to multiple recipients who did not ask for them. The problems caused by spam are due to the combination of the unsolicited and bulk aspects; the quantity of unwanted messages swamps messaging systems and drowns out the messages that recipients do want. Spam has been a problem in many different media, and invariably arises whenever a medium allows people to send many messages without per-message charges.