Assuming that, that is homework, you should at least try to understand what that code does, well anyways,
here's teh codes
ValentinesDay.java
Code:
import java.util.Scanner;
//import javax.swing.JOptionPane;
public class ValentinesDate {
public static void main(String[] args)
{
//using at least one of each type listed below:
//String used 4 times
//int used once
//double used once
//char used once
//boolean used once
Scanner keyboard = new Scanner(System.in);
double totalSpent;
int numberOfRoses ;
char gender;
boolean lucky;
String datesName1, restaurantName, feelinglucky ;
System.out.println("What is your dates name?");
datesName1 = keyboard.next();
System.out.println("What gender is your date?");
String sGender = keyboard.next();
gender = sGender.charAt(0);
System.out.println("Where are you taking your date?");
restaurantName = keyboard.next();
System.out.println("How many roses are you bringing?");
numberOfRoses = keyboard.nextInt();
System.out.println("How much do you plan on spending?");
totalSpent = keyboard.nextDouble();
System.out.println("Are you feeling lucky?");
feelinglucky = keyboard.next();
if (feelinglucky.equals("true"))
lucky=true;
else
lucky=false;
System.out.println("Name: "+datesName1);
System.out.println("Gender: "+gender);
System.out.println("Place: "+restaurantName);
System.out.println("Number of Roses: "+numberOfRoses);
System.out.println("Total Spent: $"+totalSpent);
System.out.println("Got Lucky: "+lucky);
}
}
Example Usage:
Input:
What is your dates name?
Oprah
What gender is your date?
f
Where are you taking your date?
McDonalds
How many roses are you bringing?
1
How much do you plan on spending?
12,50 //had to use the comma , cuz in germany we have different conventions
Are you feeling lucky?
true
Output:
Name: Oprah
Gender: f
Place: McDonalds
Number of Roses: 1
Total Spent: $12.5
Got Lucky: true
---------- Post added at 08:04 PM ---------- Previous post was at 08:02 PM ----------
I do not like how it is programmed since it's forbidden to be more object oriented :S I would put all that input and output functions into seperate methods, but .. ye