JAVA
Can you make this return the first letter of first and last name capitalized?
import java.io.File;
import java.io.IOException;
import java.util.*;
public class M1 {
public static void main(String[] args) {
//scanner input from user
Scanner scanner = new Scanner(System.in);
//
System.out.print("Please enter your full name: ");
String fullname = scanner.nextLine();
//creating a for loop to call first and last name separately
int i,k=0;
String first="",last="";
for(i=0;i<fullname.length();i++) {
char j=fullname.charAt(i);
if(j==' ') {
k=i;
break;
}
first=first+j;
}
for(i=k;i<fullname.length();i++) {
last=last+fullname.charAt(i);
}
System.out.println("First Name: " + first);
System.out.println("Last Name: " + last);
}
}
CODE:
import java.io.File;
import java.io.IOException;
import java.util.*;
public class Main {
public static void main(String[] args) {
//scanner input from user
Scanner scanner = new Scanner(System.in);
//
System.out.print("Please enter your full name:
");
String fullname = scanner.nextLine();
//creating a for loop to call first and last
name separately
int i,k=0;
String first="",last="";
for(i=0;i<fullname.length();i++) {
char
j=fullname.charAt(i);
if(j==' ') {
k=i;
break;
}
//converting first character to upper
Case
if(i==0){
j = Character.toUpperCase(j);
}
first=first+j;
}
for(i=k;i<fullname.length();i++) {
//getting each character in j
char j =
fullname.charAt(i);
// Since, at kth position there is a space, So for k+1th
position, Character case will be converted to upper Case
if(i==k+1){
j = Character.toUpperCase(j);
}
last=last+j;
}
System.out.println("First Name: " +
first);
System.out.println("Last Name: " + last);
}
}
SCREENSHOT:

JAVA Can you make this return the first letter of first and last name capitalized? import java.io.File;...
how would i use test.add because i would like to use add import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class checkFruit { private List<String> tests; public List<String> getFruit(String fruits) { tests = new ArrayList<String>(Arrays.asList(fruits.split(","))); for (String test : tests) { System.out.println(test); tests.add()//how would i use add here } return tests; } public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter file name: "); File file = new File(in.nextLine()); try { checkFruit...
For the below code find and fix the errors then tell what the output would be. import java.utils.*; public class pin public void main(String[] args); { char s; int num; Scanner br = Scanner(System.in); System.out.print("Enter the first letter of your name :"); s = BR.next().charAt(0); num = s; System.out.println(“The value associated with your letter is” num); }
JAVA: Rewrite the following code to where the inputs are from a file. The file name will be from the input from the user scanner. CODE: import java.util.*; public class Q1 { public static int sumOD (int k) { int sumOD = 0; int in = k; while (in != 0) { int digitON = in % 10; sumOD += digitON; in /= 10; } return sumOD; } public static void main(String[] args) { int n, i, k; System.out.println("Enter...
Please make the following code modular. Therefore contained in a package with several classes and not just one. import java.util.*; public class Q { public static LinkedList<String> dogs = new LinkedList<String> (); public static LinkedList<String> cats = new LinkedList<String> (); public static LinkedList<String> animals = new LinkedList<String> (); public static void enqueueCats(){ System.out.println("Enter name"); Scanner sc=new Scanner(System.in); String name = sc.next(); cats.addLast(name); animals.addLast(name); } ...
import java.util.Scanner; public class TriangleMaker { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Welcome to the Triangle Maker! Enter the size of the triangle."); Scanner keyboard = new Scanner(System.in); int size = keyboard.nextInt(); for (int i = 1; i <= size; i++) { for (int j = 0; j < i; j++) { System.out.print("*"); } System.out.println(); } for (int...
Java Project
Draw a class diagram for the below class (using UML
notation)
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class myData {
public static void main(String[] args) {
String str;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter text (‘stop’ to quit).");
try (FileWriter fw = new FileWriter("test.txt")) {
do {
System.out.print(": ");
str = br.readLine();
if (str.compareTo("stop") == 0)
break;
str = str + "\r\n"; // add newline
fw.write(str);
} while (str.compareTo("stop") != 0);
} catch (IOException...
Change the following Shift Cipher program so that it uses OOP(constructor, ect.) import java.util.*; import java.lang.*; /** * * @author STEP */ public class ShiftCipher { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner(System.in); String plainText; System.out.print("Please enter your string: "); // get message plainText = input.nextLine(); System.out.print("Please enter your shift cipher key: "); // get s int s = input.nextInt(); int...
I don't really understand how to make the scores show up and how to make it start over. I honestly only half understand the things I've used to piece this together to make this work so far. but this is what I was asked to do..... read a user's first and last name read three integer scores, calculate the total and average determine the letter grade based on the following criteria - Average 90-100 grade is A, 80-89.99 grade is...
*JAVA Prompt the user for a movie name. Output the three movies that come alphabetically before the one entered. I need help correcting my code. I'm unsure why I am getting a name, year, and genre in my output. Input: Jericho Output: Similar title finder. Enter a movie name.\n Here are the 3 movies that are listed before the one you entered\n Jeremy Paxman Interviews...\n Jeremy Taylor\n Jeremy Vine Meets...\n Current output: Similar title finder. Enter a movie name.\n Here...
I need help debugging this Java program. I am getting this error message: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 at population.Population.main(Population.java:85) I am not able to run this program. ------------------------------------------------------------------- import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.util.Scanner; /* Linked list node*/ class node { long data; long year; String country; node next; node(String c,long y,long d) { country=c; year=y; data = d; next = null; } } public class Population { private static node head; public static void push(String...