Assignment #15 and Using Variables
Code
/// Name: Tim Chuang
/// Period: 7
/// Program Name: Using Variables
/// File Name: UsingVariables.java
/// Date Finished: 9/22/2015
public class UsingVariables
{
public static void main( String[] args )
{
int x, y;
String one, two;
double cents, sents;
x = 20;
y = 10;
one = "apples";
two = "bananas";
cents = 2.10;
sents = 3.50;
System.out.println( "I like " + one );
System.out.println( "They cost " + cents + " dollars" );
System.out.println( "I also like " + two );
System.out.println( two + " cost " + sents );
System.out.println( "I will buy " + x +" "+ two );
System.out.println( "I will also buy " + y +" "+ one );
}
}
Picture of the output