I have just started my java programming classes and i am trying to finish my first project.
I need some help figuring this out.
What i need to do is input the date in the format mm/dd/yyyy and then it will output it as dd-mm-yyyy.
This is probably a really simple problem that i am overlooking(or just to stupid to figure out...this is only my second java programming lab). Anyway is someone could help me out and possibly explain why i have to do those steps to get it to work that would be great. I did a search on google but that really did not help all that much.
I am going to show you the whole code for the project right now but really all you need is the stuff at the end.
Please help me out!!
Thanks
I need some help figuring this out.
What i need to do is input the date in the format mm/dd/yyyy and then it will output it as dd-mm-yyyy.
This is probably a really simple problem that i am overlooking(or just to stupid to figure out...this is only my second java programming lab). Anyway is someone could help me out and possibly explain why i have to do those steps to get it to work that would be great. I did a search on google but that really did not help all that much.
I am going to show you the whole code for the project right now but really all you need is the stuff at the end.
PHP:
import java.util.Scanner;
import java.util.*;
import java.text.*;
public class Lab2
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("***************************************");
System.out.println("* Welcome to your first Java program! *");
System.out.println("***************************************");
System.out.println(" ");
System.out.println("*** Test integer arithmetic ***");
System.out.println(" ");
System.out.println("Enter first integer number: ");
int value1 = keyboard.nextInt();
System.out.println("Enter second integer number: ");
int value2 = keyboard.nextInt();
int addvalue = value1 + value2;
System.out.println(value1 + " + " + value2 + " = " + addvalue);
int minusvalue = value1 - value2;
System.out.println(value1 + " - " + value2 + " = " + minusvalue);
int multiplyvalue = value1 * value2;
System.out.println(value1 + " * " + value2 + " = " + multiplyvalue);
int dividevalue = value1 / value2;
System.out.println(value1 + " / " + value2 + " = " + dividevalue);
int modulusvalue = value1 % value2;
System.out.println(value1 + " % " + value2 + " = " + modulusvalue);
System.out.println(" ");
System.out.println("*** Test real arithmetic ***");
System.out.println(" ");
System.out.println("Enter first real number: ");
double real1 = keyboard.nextDouble();
System.out.println("Enter second real number: ");
double real2 = keyboard.nextDouble();
double addreal = real1 + real2;
System.out.println(real1 + " + " + real2 + " = " + addreal);
double minusreal = real1 - real2;
System.out.println(real1 + " - " + real2 + " = " + minusreal);
double multiplyreal = real1 * real2;
System.out.println(real1 + " * " + real2 + " = " + multiplyreal);
double dividereal = real1 / real2;
System.out.println(real1 + " / " + real2 + " = " + dividereal);
System.out.println(" ");
System.out.println("*** Test String operations ***");
System.out.println(" ");
keyboard.nextLine();
System.out.println("Enter a string of characters: ");
String typedwords = keyboard.nextLine();
System.out.println("The length of string"+ " \"" + typedwords + "\"" +
" is " + typedwords.length());
System.out.println("Enter an integer between 0 and 20: ");
int stringint = keyboard.nextInt();
System.out.println("The character at index " + stringint +
" of string " + "\"" + typedwords + "\"" + " is " +
"\'" + typedwords.charAt(stringint) + "\'");
keyboard.nextLine();
System.out.println("Enter another string of characters: ");
String typedword = keyboard.nextLine();
System.out.println("The first occurence of string " + "\"" +
typedword + "\"" + " in string " + "\"" + typedwords +
"\"" + " is at position " + typedwords.indexOf(typedword));
System.out.println(" ");
System.out.println("*** One last test ***");
System.out.println(" ");
System.out.println("Enter your birthday (mm/dd/yyyy): ");
}
}
Please help me out!!
Thanks