Okay, I've run into a problem because I think the teacher went warp speed near the end of the class.
Note: DON'T help me wit the first part, I'm going to try that out when I get to a computer with a compiler.
***Test String Operations***
Enter a string of characters: The Lord of the Rings
The length of string "The Lord of the Rings" is 21
Enter an integer between 0 and 20: 10
The character at index 10 of string "The Lord of the Rings" is 'f'
Enter anoher string of characters: Lord
The first occurrence of string "Lord" in string "The Lord of the Rings" is at position 4.
That is CONFUSING me!
Here's what I have thus far (remember, if what I have isn't rigt, don't tell me please. Gnna test it out later).
import java.util.Scanner;
public class Arithmetic
{
public static void main(String [] args)
int Fi, Si
double Fd, Sd
That is what I have...CURRENTLY. I'm going to ask the user to input a number and I'll basically have to use all the mathematical operations (including modulus) using integer and double. The last part of the program is supposed to be the string and index shit which I have NO idea what to do. The lecture notes don't really tell me much.
Also, how would I go about putting in a date and such? My homework is:
Write a java program that asks the user for a date and reads th date entered by the user and finally prints a friendly message.
Would this be...?
import java.util.Scanner;
public class Date
{
public static void main(String [] args);
Scanner keyboard = new Scanner(System.in);
string = Date
System.out.println("Please enter today's date.");
Date = keyboard.nextString();
System.out.println("Today's date is:" + mm/dd/yyyy);
System.out.println("Have a nice day.");
}
}
Okay, now that I look at it...I'm doing something wrong, but I can't put my finger on it. Please help.
edit: Just to clarify...what I'm wanting help with is the date and the string index and all that shit. :P