473,385 Members | 1,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Output problem

heres my code there 1 problem with it (its bolded) its not going through its a math type things if any one can help me please help all i ask is that you no change the code too much if possible, heres my instructions:

Write a Java program that will do the following:
* ask the user to input their name and age
* ask the user to input the current year
* determine their age in year 2050
* display their name, their current age and their age in 2050 as user-friendly output



heres my code:




// The "AgeIn2050" class.
//Bob Jones
//Tuesday, Febuary 27, 2007
import java.awt.*;
import hsa.Console;

public class AgeIn2050
{
static Console c; // The output console

public static void main (String[] args)
{
c = new Console ();

String userName,yearCurrent;
int age;

c.print("Hello, what is your name?");
userName = c.readString();
c.println();
c.println(userName + ", what is the current year?");
yearCurrent = c.readString();
c.println("So the current year is " + yearCurrent);
c.println("What is your age?");
age = c.readInt();
c.println();

c.println(userName + ", you are currently " + age + ", in the year " + 2050 + ", you will be " + ((2050 - yearCurrent) + (+ age)) ".");
} // main method
} // AgeIn2050 class
Feb 28 '07 #1
1 1320
r035198x
13,262 8TB
heres my code there 1 problem with it (its bolded) its not going through its a math type things if any one can help me please help all i ask is that you no change the code too much if possible, heres my instructions:

Write a Java program that will do the following:
* ask the user to input their name and age
* ask the user to input the current year
* determine their age in year 2050
* display their name, their current age and their age in 2050 as user-friendly output



heres my code:




// The "AgeIn2050" class.
//Bob Jones
//Tuesday, Febuary 27, 2007
import java.awt.*;
import hsa.Console;

public class AgeIn2050
{
static Console c; // The output console

public static void main (String[] args)
{
c = new Console ();

String userName,yearCurrent;
int age;

c.print("Hello, what is your name?");
userName = c.readString();
c.println();
c.println(userName + ", what is the current year?");
yearCurrent = c.readString();
c.println("So the current year is " + yearCurrent);
c.println("What is your age?");
age = c.readInt();
c.println();

c.println(userName + ", you are currently " + age + ", in the year " + 2050 + ", you will be " + ((2050 - yearCurrent) + (+ age)) ".");
} // main method
} // AgeIn2050 class
Try


Expand|Select|Wrap|Line Numbers
  1.  
  2. c.println(userName + ", you are currently " + age + ", in the year 2050, you will be " + ((2050 - yearCurrent) + age)+ ".");
  3.  
  4.  
Feb 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jay Chan | last post by:
I am trying to use a command line program to run a stored procedure that generates output in a comma-delimitted format. Somehow, ISQL or OSQL always wrap the lines at 256 characters. I believe this...
1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
11
by: Etienne Charland | last post by:
Hi, I have a solution containing 6 C# projects; 1 WinForms project and 5 class libraries. I didn't have any problems until recently. I added a new project containing reports. I am using...
3
by: Dalan | last post by:
Perhaps someone has experienced this problem. I developed an Access 97 Runtime database on a Windows 98 SE machine. I have three reports that can be optionally copied to a floppy disk or hard drive...
5
by: Tom Lam lemontea | last post by:
Hi all, This is my very first post here, I've seriously tried some programming on C, and shown below is my very first program(So you can expect it to be very messy) that I wrote after I've learned...
4
by: Mountain Bikn' Guy | last post by:
I am having serious problems with the following IDE bug: Could not write to output file 'x.dll' -- 'The process cannot access the file because it is being used by another process. ' and BUG:...
5
by: Brad | last post by:
I created a base page class which sets a response filter and the filter injects additional html into the response output stream. The filter works fine and everything works as expected except for...
6
by: Alec MacLean | last post by:
Hi, I've created a small application for our company extranet (staff bulletins) that outputs a list of links to PDF's that are stored in a SQL table. The user clicks a link and the PDF is...
4
by: Jon | last post by:
Hi, I used XslCompiledTransform with the following Xsl file. The <xsl:text disable-output-escaping="yes"does not work when using XslCompiledTransform to do the trnasform (namely the output...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.