Question

In: Computer Science

Write a program in java which is in main and uses no classes, methods, loops or...

Write a program in java which is in main and uses no classes, methods, loops or if statements Ask the user to enter their first name Ask the user to enter their last name Print their initials followed by periods (ie. Clark Kent = C. K.) Print the number of letters in their last name

Solutions

Expert Solution

Program Code Screenshot:

Sample output:

The screenshots are attached below for reference.

Please follow them for proper indentation and output.

Please see that no additional classes,loops and methods are used.

Program to copy:

import java.util.*;
public class Main
{
   public static void main(String[] args) {
   Scanner inp=new Scanner(System.in);
   String f,l;
       System.out.println("Enter first name:");
       f=inp.next();//read first and last names
       System.out.println("Enter last name:");
       l=inp.next();
       System.out.print(f.charAt(0)+"."+l.charAt(0)+".");//print first letters with periods
       System.out.println();
       System.out.println("The number of letters in last name:"+l.length());//print number of last name characters
      
   }
}


Related Solutions

Write a Java program that uses nested for loops to print a multiplication table as shown...
Write a Java program that uses nested for loops to print a multiplication table as shown below.   Make sure to include the table headings and separators as shown.   The values in the body of the table should be computed using the values in the heading   e.g. row 1 column 3 is 1 times 3.
3) Create a Java program that uses NO methods, but use scanner: Write a program where...
3) Create a Java program that uses NO methods, but use scanner: Write a program where you will enter the flying distance from one continent to another, you will take the plane in one country, then you will enter miles per gallon and price of gallon and in the end it will calculate how much gas was spend for that distance in miles. Steps: 1) Prompt user to enter the name of country that you are 2) Declare variable to...
Write a program in java that uses methods to input data for calculation, calculate, and display...
Write a program in java that uses methods to input data for calculation, calculate, and display the results of the calculations. That is, there are at least three methods. The problem is to write a program that calculates the area of a rectangle. This action should be repeatable.
write a java code program using loops to compute the sum of the 30 terms of...
write a java code program using loops to compute the sum of the 30 terms of the series below. Find sum of all integers between 100 and 200 which are divisible by 9 or 13 Write a program to find the sum of the first 8 terms of the series 1 + 11 + 111 + 1111 + . . . Output: Term Ratio Sum
Objective: Create a program that uses the methods in the String and Math classes to do...
Objective: Create a program that uses the methods in the String and Math classes to do the following: Ask the user to enter two nouns Tell the user how many letters the nouns are from eachother in the dictionary. Tell the user the last letter of each of the nouns Tell the user the position of the letter "e" in each of the nouns, -1 if no "e" exists in the word. For full credit, you must use quotations around...
Write a Java program that uses the file EnglishWordList.txt which contains a collection of words in...
Write a Java program that uses the file EnglishWordList.txt which contains a collection of words in English (dictionary), to find the number of misspelled words in a story file called Alcott-little-261.txt. Please note that the dictionary words are all lower-cased and there are no punctuation symbols or numbers. Hence it is important that you eliminate anything other than a-z and A-Z and then lower case story words for valid comparisons against the WordList file. When you read each line of...
Write a Java program that uses the file EnglishWordList.txt which contains a collection of words in...
Write a Java program that uses the file EnglishWordList.txt which contains a collection of words in English (dictionary), to find the number of misspelled words in a story file called Alcott-little-261.txt. Please note that the dictionary words are all lower-cased and there are no punctuation symbols or numbers. Hence it is important that you eliminate anything other than a-z and A-Z and then lower case story words for valid comparisons against the WordList file. When you read each line of...
Write a java program that will ask the user to enter integers (use loops) until -100...
Write a java program that will ask the user to enter integers (use loops) until -100 is entered. The program will find and display the greatest, the smallest, the sum and the average of the entered numbers. also write a separate driver class which will be used to run and display the greatest, the smallest, the sum and the average of the entered numbers. Thanks!!
IN C++ Write a program that uses nested loops to collect data and calculate the average...
IN C++ Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask the user for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the ­­program should display the...
write a program that uses exactly four for loops to print the sequence of letters below...
write a program that uses exactly four for loops to print the sequence of letters below A A A A A A A A A A B B B B B B B C C C C C C E E E E E
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT