473,378 Members | 1,388 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,378 software developers and data experts.

Java Questions

Instructions:

My project uses one class to convert a value entered by the user in yards to meters and feet. The program should print the results of each conversion to the screen without the user having to re-enter the value to be converted.
The name of your class should be YardsConversion.The program should have the user enter a type double value for yards using the keyboard.
The class should contain a main method to enter the value in yards to be converted. It should also contain two other methods to make the calculations to meters and feet respectively and then print the results to the DOS screen.

My attempt and questions:

import java.util.*;
public class YardsConversion
{
public static final double yards: ;
public static final double meters: ;
public static final double feet: ;

public static double yards=0
public static double meters=0
public static double feet=0

public static void output()

{


Scanner scannerObject = new Scanner(System.in);

System.out.println("This program allows you to convert a value entered by the
user in yards to meters to feet without the user having to re-enter the value to be converted.");



I don't know if this is the correct way to start or not? I would like to know the command or example of a command to use to execute this. Thanks.
Mar 28 '07 #1
4 1547
r035198x
13,262 8TB
Instructions:

My project uses one class to convert a value entered by the user in yards to meters and feet. The program should print the results of each conversion to the screen without the user having to re-enter the value to be converted.
The name of your class should be YardsConversion.The program should have the user enter a type double value for yards using the keyboard.
The class should contain a main method to enter the value in yards to be converted. It should also contain two other methods to make the calculations to meters and feet respectively and then print the results to the DOS screen.

My attempt and questions:

import java.util.*;
public class YardsConversion
{
public static final double yards: ;
public static final double meters: ;
public static final double feet: ;

public static double yards=0
public static double meters=0
public static double feet=0

public static void output()

{


Scanner scannerObject = new Scanner(System.in);

System.out.println("This program allows you to convert a value entered by the
user in yards to meters to feet without the user having to re-enter the value to be converted.");



I don't know if this is the correct way to start or not? I would like to know the command or example of a command to use to execute this. Thanks.
Follow the instructions in the question.

It says you should have
1.)A main method
2.)Two more methods toMeters and toFeet
Mar 28 '07 #2
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3.  
  4.  
  5. public class YardsConversion
  6.  
  7. {
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.             public static final double YARD2METER = .9144;
  15.  
  16.             public static final double METER2FEET =  3.280;
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.             public static double yard =0;
  29.  
  30.             public static double meter =0;
  31.  
  32.             public static double feet = 0;
  33.  
  34.             public static double YARD2METER = 0;
  35.  
  36.             public static int METER2FEET =0;
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.             public static void output()
  52.  
  53.             {
  54.  
  55.  
  56.  
  57.                         Scanner scannerObject = new Scanner(System.in);
  58.  
  59.  
  60.  
  61.                         System.out.println("This program allows you to convert yard");
  62.  
  63.                         System.out.println("to meter and feet");
  64.  
  65.                           System.out.println(" ");
  66.  
  67.                         System.out.print("\n");
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.             }                 
  82.  
  83.  
  84.  
  85.  
  86.  
  87.             public static void yard2meter()
  88.  
  89.  
  90.  
  91.             {
  92.  
  93.                                     Scanner scannerObject = new Scanner(System.in);
  94.  
  95.  
  96.  
  97.                                     /***Prompt to tell the user what to do next. ***/
  98.  
  99.  
  100.  
  101.                                     System.out.print("Enter a temperature in yard.  ");
  102.  
  103.  
  104.  
  105.                                     /***Assigns number entered by user to
  106.  
  107.                                     variable named yard2meter ***/
  108.  
  109.  
  110.  
  111.                                     yard2meter = scannerObject.nextDouble();
  112.  
  113.  
  114.  
  115.  
  116.  
  117.                                     /***  Shows the end user the value they
  118.  
  119.                                     entered via the keyboard ***/
  120.  
  121.  
  122.  
  123.                                     System.out.print("\n\n");
  124.  
  125.                                     System.out.println("\n You entered " + yard2meter + " yard.");
  126.  
  127.  
  128.  
  129.                                     /*** Formula to convert yards to meter and
  130.  
  131.                                    assign the results to a variable named meter. ***/
  132.  
  133.  
  134.  
  135.                                     meter =  YARD2METER * tempCent + 32;
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.                    System.out.println(YARD2METER + " YARDS IS EQUAL TO " +  .");
  145.  
  146.  
  147.  
  148.  
  149.  
  150.                            /***Used to print a blank line to the screen***/
  151.  
  152.  
  153.  
  154.                                     System.out.print("\n");
  155.  
  156.  
  157.  
  158.             }               /***  end  method  ***/
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.             public static void METER2FEET()
  167.  
  168.  
  169.  
  170.             {
  171.  
  172.                                     Scanner scannerObject = new Scanner(System.in);
  173.  
  174.  
  175.  
  176.                                     /***Prompt to tell the user to enter a 
  177.                                     value.   ***/
  178.  
  179.  
  180.  
  181.  
  182.  
  183.                                     System.out.print("Enter a temperature in feet.");
  184.  
  185.  
  186.  
  187.                                     /***Assigns number entered by user to
  188.  
  189.                                     variable named METER2FEET***/
  190.  
  191.  
  192.  
  193.                                     METER2FEET = scannerObject.nextDouble();
  194.  
  195.  
  196.  
  197.                                     /***  Shows the end user the value they
  198.  
  199.                                     entered via the keyboard ***/
  200.  
  201.  
  202.  
  203.                                     System.out.print("\n");
  204.  
  205.                                     System.out.println("\n You entered " + METER2FEET + " .");
  206.  
  207.  
  208.  
  209.  
  210.  
  211.                                     /*** Formula to convert  and
  212.  
  213.                                     assign the results to a variable named cent. ***/
  214.  
  215.  
  216.  
  217.                                    METER =  () * ;
  218.  
  219.  
  220.  
  221.                                     /***Outputs the value assigned to  and to the
  222.  
  223.                                     screen along with some explanatory words so the user can understand
  224.  
  225.                                     what is happening.  ***/
  226.  
  227.  
  228.  
  229.                                     System.out.println(METER2FEET + " FEET " + FEET)
  230.  
  231.                                                                                                                         + " degrees Centigrade.");
  232.  
  233.  
  234.  
  235.                                     /***Used to print a blank line to the screen***/
  236.  
  237.  
  238.  
  239.                                     System.out.print("\n");
  240.  
  241.  
  242.  
  243.             }                /*** end of  method ***/
  244.  
  245.  
  246.  
  247. }                      /*  end of class YardsConversion  */
  248.  
  249.  
Mar 29 '07 #3
I truly do not know where to begin. This is all I have and I have a major headache. This assignment is due in two days and I need MAJOR pointers. I have never done this before!!!! Brand new to JAVA and major assingment. I learn quick just need help with this. What am I doing wrong? Help!!
Mar 29 '07 #4
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3.  
  4.  
  5. public class YardsConversion
  6.  
  7. {
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.             public static final double YARD2METER = .9144;
  15.  
  16.             public static final double METER2FEET =  3.280;
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.             public static double yard =0;
  29.  
  30.             public static double meter =0;
  31.  
  32.             public static double feet = 0;
  33.  
  34.             public static double YARD2METER = 0;
  35.  
  36.             public static int METER2FEET =0;
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.             public static void output()
  52.  
  53.             {
  54.  
  55.  
  56.  
  57.                         Scanner scannerObject = new Scanner(System.in);
  58.  
  59.  
  60.  
  61.                         System.out.println("This program allows you to convert yard");
  62.  
  63.                         System.out.println("to meter and feet");
  64.  
  65.                           System.out.println(" ");
  66.  
  67.                         System.out.print("\n");
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.             }                 
  82.  
  83.  
  84.  
  85.  
  86.  
  87.             public static void yard2meter()
  88.  
  89.  
  90.  
  91.             {
  92.  
  93.                                     Scanner scannerObject = new Scanner(System.in);
  94.  
  95.  
  96.  
  97.                                     /***Prompt to tell the user what to do next. ***/
  98.  
  99.  
  100.  
  101.                                     System.out.print("Enter a temperature in yard.  ");
  102.  
  103.  
  104.  
  105.                                     /***Assigns number entered by user to
  106.  
  107.                                     variable named yard2meter ***/
  108.  
  109.  
  110.  
  111.                                     yard2meter = scannerObject.nextDouble();
  112.  
  113.  
  114.  
  115.  
  116.  
  117.                                     /***  Shows the end user the value they
  118.  
  119.                                     entered via the keyboard ***/
  120.  
  121.  
  122.  
  123.                                     System.out.print("\n\n");
  124.  
  125.                                     System.out.println("\n You entered " + yard2meter + " yard.");
  126.  
  127.  
  128.  
  129.                                     /*** Formula to convert yards to meter and
  130.  
  131.                                    assign the results to a variable named meter. ***/
  132.  
  133.  
  134.  
  135.                                     meter =  YARD2METER * tempCent + 32;
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.                    System.out.println(YARD2METER + " YARDS IS EQUAL TO " +  .");
  145.  
  146.  
  147.  
  148.  
  149.  
  150.                            /***Used to print a blank line to the screen***/
  151.  
  152.  
  153.  
  154.                                     System.out.print("\n");
  155.  
  156.  
  157.  
  158.             }               /***  end  method  ***/
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.             public static void METER2FEET()
  167.  
  168.  
  169.  
  170.             {
  171.  
  172.                                     Scanner scannerObject = new Scanner(System.in);
  173.  
  174.  
  175.  
  176.                                     /***Prompt to tell the user to enter a 
  177.                                     value.   ***/
  178.  
  179.  
  180.  
  181.  
  182.  
  183.                                     System.out.print("Enter a temperature in feet.");
  184.  
  185.  
  186.  
  187.                                     /***Assigns number entered by user to
  188.  
  189.                                     variable named METER2FEET***/
  190.  
  191.  
  192.  
  193.                                     METER2FEET = scannerObject.nextDouble();
  194.  
  195.  
  196.  
  197.                                     /***  Shows the end user the value they
  198.  
  199.                                     entered via the keyboard ***/
  200.  
  201.  
  202.  
  203.                                     System.out.print("\n");
  204.  
  205.                                     System.out.println("\n You entered " + METER2FEET + " .");
  206.  
  207.  
  208.  
  209.  
  210.  
  211.                                     /*** Formula to convert  and
  212.  
  213.                                     assign the results to a variable named cent. ***/
  214.  
  215.  
  216.  
  217.                                    METER =  () * ;
  218.  
  219.  
  220.  
  221.                                     /***Outputs the value assigned to  and to the
  222.  
  223.                                     screen along with some explanatory words so the user can understand
  224.  
  225.                                     what is happening.  ***/
  226.  
  227.  
  228.  
  229.                                     System.out.println(METER2FEET + " FEET " + FEET)
  230.  
  231.                                                                                                                         + " degrees Centigrade.");
  232.  
  233.  
  234.  
  235.                                     /***Used to print a blank line to the screen***/
  236.  
  237.  
  238.  
  239.                                     System.out.print("\n");
  240.  
  241.  
  242.  
  243.             }                /*** end of  method ***/
  244.  
  245.  
  246.  
  247. }                      /*  end of class YardsConversion  */
  248.  
  249.  
The two methods are supposed to be yardsToFeet and yardsToMetres
Mar 29 '07 #5

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

Similar topics

55
by: Elijah | last post by:
I have read many of the topics on learning C++ or Java first. It seems like everyone says something different. I would like to know if I should learn C++ or Java. First a little about myself. I...
8
by: Beatrice Rutger | last post by:
Hi, I am a previous Micro$oft desertee (moved from VB/VC++ to Java before this whole DOTNET thing) because I had several issues with Micro$oft. I am not completely in love with Windoze, but I...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
20
by: mayershome | last post by:
Hi! I'dont have any experiences in programming... what language should I start learning???? C? C++ or Java`? greetz
0
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of attending interviews. If you own a company best way to judge if...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
2
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate...
0
by: neelesh kumar | last post by:
sir, i have a java applet.i am using msaccess database . Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"). in my program i want to get questions from access table questions in a new frame...
1
by: saytri | last post by:
Hi i'm a student studying java (i'm still a beginner). i have a project were i have to do a quiz with a set of questions. So i think that i have to type the questions in a textfile for example in...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.