Need help calling and looping custom classes
Hi, I am writing a code with custom classes in it and another program that calls upon all of the classes in the first program. I can get the second one (L6) to call upon and execute all of the classes of the first (Foreign). However, I need the second one to loop until quit is selected from the menu on Foreign and I can't seem to figure out how to do it. Here are the codes:
L6:
public class lab6
public static void main(String[] args)
Foreign camount = new Foreign();
camount = new Foreign();
camount.get();
camount.print();
camount.intake();
camount.convert();
camount.vertprint();
System.out.println(camount);
Foreign:
import java.util.Scanner;
public class Foreign
private String country;
private int choice;
private float dollars;
private float conversionValue;
private float conversionAmount;
public Foreign()
country = "null";
choice = 0;
dollars = 0;
conversionValue = 0;
conversionAmount = 0;
public void get()
Scanner Keyboard = new Scanner(System.in);
System.out.println("Foreign Exchange\n\n");
System.out.println("1 = U.S. to Canada");
System.out.println("2 = U.S. to Mexico");
System.out.println("3 = U.S. to Japan");
System.out.println("4 = U.S. to Euro");
System.out.println("0 = Quit");
System.out.print("\nEnter your choice: ");
choice = Keyboard.nextInt();
public void print()
System.out.print("\nYou chose " + choice);
public void intake()
Scanner Keyboard = new Scanner(System.in);
if (choice >= 1 && choice <= 4)
switch (choice)
case 1: System.out.println("\nU.S. to Canada");
conversionValue = 1.1225f;
country = ("Canadian Dollars");
break;
case 2: System.out.println("\nU.S. to Mexico");
conversionValue = 10.9685f;
country = ("Mexican Pesos");
break;
case 3: System.out.println("\nU.S. to Japan");
conversionValue = 118.47f;
country = ("Japanese Yen");
break;
case 4: System.out.println("\nU.S. to Euro");
conversionValue = 0.736377f;
country = ("European Union Euros");
break;
System.out.print("\nEnter U.S. dollar amount: ");
dollars = Keyboard.nextFloat();
public void convert()
conversionAmount = conversionValue * dollars;
public void vertprint()
System.out.println("\nCountry = " + country);
System.out.println("Rate = " + conversionValue);
System.out.println("Dollars = " + dollars);
System.out.println("Value = " + conversionAmount);
public String toString()
String line;
line = "\n" + country + " " + conversionValue + " " + dollars + " " + conversionAmount;
return line;
I appreciate any help anyone can give me. This is driving me crazy. Thanks.
1. first you need to write method to get choice value from Foreign class.
simply add this method.
public class Foreign {
// ... Add this
public int getChoice() {
return choice;
}2. Then in your main, you can obtain with previos method.
public static void main(String[] args) {
Foreign camount = new Foreign();
// remove this. you alredy create an instance in last statement.
//camount = new Foreign();
int choice = 0;
do {
camount.get();
choice = camount.getChoice();
// your process...
} while (choice != 0);
}
Similar Messages
-
Re: Beginner needs help using a array of class objects, and quick
Dear Cynthiaw,
I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
Is there a way to discard and replace a post (with html source code) in the Sun forum ?
Thanks for your help.
Chavadachavada wrote:
Dear Cynthiaw,
I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
[code]
public class Foo() {
* This is the bar method
public void bar() {
// do stuff
}[/code] -
I need help deleting and adding text
i need help deleting and adding text, can soneone help
Adobe Photoshop Elements 10You should delete your phone number from the topic line.
Spambots search these forums for contact info.
You don't want to get even more telemarketing/scam calls than you probably already get.
It seems like the "Do Not Call" lists are ignored these days.
Message was edited by: Bo LeBeau Looks like someone already took care of this. -
I need help scrolling and highlighting for a vast amount of pics that I'm trying to transfer. I have a macbook pro osx 10.5.8
I need help scrolling and highlighting for a vast amount of pics that I'm trying to transfer. I have a macbook pro osx 10.5.8
-
Need Help in trying to understand class objects
I need help on understanding following problem.I have two files for that, which are as follows:
first file
public class Matrix extends Object {
private int matrixData[][]; // integer array to store integer data
private int rowMatrix; // number of rows
private int colMatrix; // number of columns
public Matrix( int m, int n )
{ /*Constructor: initializes rowMatrix and colMatrix,
and creates a double subscripted integer array matrix
of rowMatrix rows and colMatrixm columns. */
rowMatrix = m;
colMatrix = n;
matrixData = new int[rowMatrix][colMatrix];
public Matrix( int data[][] )
{ /* Constructor: creates a double subscripted integer array
and initilizes the array using values of data[][] array. */
rowMatrix = data.length;
colMatrix = data[0].length;
matrixData = new int [rowMatrix][colMatrix];
for(int i=0; i<rowMatrix; i++)
for(int j=0; j<colMatrix; j++)
matrixData[i][j] = data[i][j];
public int getElement( int i, int j)
{ /* returns the element at the ith row and jth column of
this matrix. */
return matrixData[i][j];
public boolean setElement( int x, int i, int j)
{ /* sets to x the element at the ith row and jth column
of this matrix; this method should also check the
consistency of i and j (i.e., if i and j are in the range
required for subscripts; only in this situation the operation
can succeed); the method should return true if the operation
succeeds, and should return false otherwise.
for(i=0;i<rowMatrix;i++){
for(j=0;j<colMatrix;j++){
x = matrixData[i][j];
if(i<rowMatrix && j<colMatrix){
return true;
else{
return false;
public Matrix transposeMatrix( )
{ /*returns a reference to an object of the class Matrix,
that contains the transpose of this matrix. */
Verify tata;
Matrix trans;
//Matrix var = matrixData[rowMatrix][colMatrix];
for(int row=0;row<rowMatrix;row++){
for(int col=0;col<colMatrix;col++){
matrixData[rowMatrix][colMatrix] = matrixData[colMatrix][rowMatrix];
trans = new Matrix(matrixData);
return trans;
public Matrix multipleMatrix( Matrix m )
/*returns a reference to an object of the class Matrix,
that contains the product of this matrix and matrix m. */
m = new Matrix(matrixData);
//Matrix var = matrixData[rowMatrix][colMatrix];
for(int row=0;row<rowMatrix;row++){
for(int col=0;col<colMatrix;col++){
//trans[row][col] = getElement(row,col);
return m;
public int diffMatrix( Matrix m )
/*returns the sum of the squared element-wise differences
of this matrix and m ( reference to the formula in the description
of assignment 5) */
return 0;
public String toString( )
/* overloads the toString in Object */
String output = " row = " + rowMatrix + " col="+colMatrix + "\n";
for( int i=0; i<rowMatrix; i++)
for( int j=0; j<colMatrix; j++)
output += " " + getElement(i,j) + " ";
output += "\n";
return output;
Second file
public class Verify extends Object {
public static void main( String args[] )
int[][] dataA = {{1,1,1},{2,0,1},{1,2,0},{4,0,0}}; // data of A
int[][] dataB = {{1,2,2,0},{1,0,3,0},{1,0,3,4}}; // data of B
Matrix matrixA = new Matrix(dataA); // matrix A
System.out.println("Matrix A:"+matrixA);
Matrix matrixB = new Matrix(dataB); // matrix B
System.out.println("Matrix B:"+matrixB);
// Calculate the left-hand matrix
Matrix leftFormula = (matrixA.multipleMatrix(matrixB)).transposeMatrix();
System.out.println("Left Side:"+leftFormula);
// Calculate the right-hand matrix
Matrix rightFormula = (matrixB.transposeMatrix()).multipleMatrix(matrixA.transposeMatrix());
System.out.println("Right Side:"+rightFormula);
// Calculate the difference between left-hand matrix and right-hand matrix
// according to the formula in assignment description
double diff = leftFormula.diffMatrix(rightFormula);
if( diff < 1E-6 ) // 1E-6 is a threshold
System.out.println("Formula is TRUE");
else
System.out.println("Formula is FALSE");
}My basic aim is to verify the formula
(A . B)' =B' . A' or {(A*B)tranpose = Btranspose * A transpose}Now My problem is that I have to run the verify class file and verify class file will call the matrix class and its methods when to do certain calculations (for example to find left formula it calls tranposematrix() and multipleMatrix();)
How will I be able to get the matrix which is to be transposed in transposeMatrix method (in Matrix class)becoz in the method call there is no input for transposematrix() and only one input for multipleMatrix(matrix m).
please peeople help me put in this.
thanking in advancePlease don't crosspost.
http://forum.java.sun.com/thread.jspa?threadID=691969
The other one is the crosspost.Okay, whatever. I'm not really concerned with which one is the original. I just view the set of threads overall as being a crosspost, and arbitrarily pick one to point others toward.
But either way
knightofdurham... pick one thread and post only in
the one.Indeed. And indicate such in the other one. -
I need help, CFquery and SQL NOT BETWEEN
OK I am building a hotel booking system as a college project and I'm having trouble with finding rooms that are available. Now I have got this working, to an extent, So to give you the bigger picture al try and lay this out the best I can so you can understand.
This is my database structure:
Bookings Table
Rooms Table
Customers Table
BookingID
BookingDateIN
BookingDateOUT
RoomID
CustomerID
RoomID
RoomType
RoomNumber
RoomPrice
Room Description
CustomerID
FullName
AddressLine1
AddressLine2
PostalCode
CarReg
OK, now you can see how this is going to work with the Bookings Tables RoomID and CustomerID matching the others to make a relationship, simple databasing.
Now I have a page that lets you select a date and then select how many days the customer wants to stay for. So the selected date will be put towards the BookingDateIN field and the calculated date will be put towards the BookingDateOUT in a NOT BETWEEN SQL statement.
I have got this to work with some test data, how ever when I select a date range that is below the 5th day in any month it shows the rooms are booked and not available even though the test data does not contain any days below the 5th.
This is my test data in the Bookings Table:
BookingID
BookingDateIN
BookingDateOUT
CustomerID
RoomID
1
20/05/2010
23/05/2010
2
2
2
26/05/2010
28/05/2010
1
5
And here is my code for the bookings page:
<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif isDefined("FORM.SearchRooms")>
<!-- adds the number of days to the selected date -->
<cfset #CalDate# = #DateFormat( DateAdd( 'd', #FORM.SelDays#, #FORM.SelDate# ), 'dd/mm/yyyy' )#>
<!-- Queries the Bookings table with a crazy NOT BETWEEN SQL Statement -->
<cfquery name="Check_Rooms_RS" datasource="HotelBookingSystem" username="HBSuser" password="HBSpass">
SELECT *
FROM Bookings
WHERE BookingDateIN AND
BookingDateOUT NOT BETWEEN
<cfqueryparam value="#FORM.SelDate#" cfsqltype="cf_sql_timestamp">
AND
<cfqueryparam value="#CalDate#" cfsqltype="cf_sql_timestamp">
</cfquery>
<!-- Now this is my beginner CFQuery'n lol it queries the Rooms table with the values output from the bookings query and loops, then I put a 0 at the end to have the correct SQL statement lol I'm trying -->
<cfquery name="Rooms_RS" datasource="HotelBookingSystem" username="HBSuser" password="HBSpass">
SELECT *
FROM Rooms
WHERE RoomID = <cfloop query="Check_Rooms_RS">#RoomID# OR </cfloop>0
</cfquery>
</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hotel Booking System - User Manager</title>
<link rel="stylesheet" type="text/css" href="../style.css"/>
</head>
<body>
<div class="container">
<div class="booking_choose_date">
<cfparam name="PreSelDate" default="#LSDateFormat(Now(), 'dd/mm/yyyy')#">
<cfif isDefined("FORM.SearchRooms")>
<cfset #PreSelDate# = #FORM.SelDate#>
</cfif>
<cfform name="form1" width="375" height="350" action="#currentpage#">
<!-- Date Picker -->
<cfinput type="DateField" name="SelDate" label="Block out starts" width="100" value="#PreSelDate#" mask="DD/MM/YYYY">
<!-- Day Picker -->
<cfselect size="1" name="SelDays" required="Yes" message="Select days staying">
<option value="1" selected>1 Day</option>
<option value="2">2 Days</option>
<option value="3">3 Days</option>
<option value="4">4 Days</option>
<option value="5">5 Days</option>
<option value="6">6 Days</option>
<option value="7">7 Days</option>
</cfselect>
<cfinput type="Submit" name="SearchRooms" value="Check" width="100">
</cfform>
</div>
<cfif isDefined("FORM.SearchRooms")>
<div class="search_results">
<!-- Outputs the Bookings table RoomID values -->
<cfoutput query="Check_Rooms_RS">
#Check_Rooms_RS.RoomID#
</cfoutput>
<!-- Outputs the Rooms table RoomID values -->
<cfoutput query="Rooms_RS">
#Rooms_RS.RoomType#
</cfoutput>
</div>
</cfif>
</div>
</body>
</html>
Little help with this would be amazing !!I only skimmed this thread. But even ignoring the myriad of date issues, the queries have a serious "logic" problem. If you think about it, does searching for rooms that are not reserved in a table that only contains reserved rooms really make sense? Say you have twenty (20) rooms. If only two (2) of them are reserved (ie in the Bookings table), how is that first query supposed to account for the other eighteen (18)?
It would make more sense to search the Bookings table for rooms that are reserved. Then query your Rooms table for rooms not in that list (ie available). Granted that is not a very efficient method for a real application. But should work for your purposes.
This is my test data in the Bookings Table:
Are you storing the booking dates as strings? Dates should be stored in a date/time column. Storing them as strings creates all kinds of problems. Not to mention it makes it more difficult to use your database's date functions. -
Need help to develop a custom connector
I need some help on developing the custom connector to Homegrown application and the version i am using is OIM9.0.3
First of all what are the steps do we need to care while developing a custom connector.
I can't able to find the process in google to develop the custom connector.
If you have any data regarding the development of custom connector, plz share to me....
What are the thing do we need to take care while developing the connector.
I referred in OIM9.1 version there was an option to develop the Custom connector by using Genric technology, can we create the custom connector by using the GTC feature in OIM 9.1
early response will be appreciatedThe docs for the new GTC framework are here: http://download.oracle.com/docs/cd/E10391_01/doc.910/e10360/about.htm#Toc153968019. GTC is useful if you target application exposes standards-based SPML (Service Provisioning Markup Language) user management interfaces, although it sounds like this isn't the case for you.
You will most likely need to go the traditional route in terms of connector development, which involves building OIM Process Task Adapters to invoke the application API's (I assume they're Java?) and invoking those adapters from within an OIM Provisioning Process.
Rob -
I'm a beginner. I'm trying to get this output
Initial number of stars:
7
Here's my program. What's wrong with it? Please help
import java.io.*;
class starWedge
public static void main (String[] args ) throws IOException
int numStars; // the number of stars
int row ; // current row number
int star; // the number of stars in this row so far
BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
String inputData;
// collect input data from user
System.out.println( "Initial number of stars:" );
inputData = userin.readLine();
numStars = Integer.parseInt( inputData );
row = 1;
while ( row <= numStars )
star = 1;
star = numStars - star;
System.out.print("*");
star = star + 1;
System.out.println(); // end each line
row = row + 1;Okay the one thing that I see immediately is that your while loop never actully exits. Not once. Why? Well simple your exit condition is the row <= numStars, yet nither numStars nor row actually change their values within the loop. In short row always equals 1 and thus never is equal to greater than numStars and the while loop does not terminate.
Second thing is that your star drawing logic is not correct. Meaning you have not told to draw the specific number of stars in one given line. For starters the System.out.println() command should be in the loop not outside it. For your purposes a for-loop nested within a while-loop is much better.
If you think you know what's wrong your program than read no further and go try it on your own. But if you still have no clue below is my modification of your code that actually produces the pattern you want, it might provide you with more hints.
import java.io.*;
class starWedge{
public static void main (String[] args ) throws IOException{
int numStars; // the number of stars
int row ; // current row number
int star; // the number of stars in this row so far
BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
String inputData;
// collect input data from user
System.out.println( "Initial number of stars:" );
inputData = userin.readLine();
numStars = Integer.parseInt( inputData );
row = 1;
while (numStars > 0){
for(star = 1; star<=numStars; star++){
System.out.print("*");
numStars = numStars - 1;
System.out.println(); // end each line
} -
I need help with a loop within an hour
I need to make a loop that gives 100, 10, 1000, 100, 10000, 1000...
I can use a for loop, if loop, while loop, and do while loop.
Thankswarnerja wrote:
sharkura wrote:
warnerja wrote:
sharkura wrote:
Sorry warnerja. I know I should have done the same. I just couldn't help myself. I need to keep telling rubbish.
:D
¦ {ÞIt's not too late to edit your spoon-fed solution, though the OP may have seen and copied it by now.And you know this isn't going to make the OP a programmer, unless he/she/it changes his/her/its stripes.
¦ {ÞYes, but its laziness will continue to be encouraged more than it should.Nah. It'll crash and burn on the next assignment.
¦ {Þ -
I need help, motherboard and RAM
Tomorrow morning I have to buy all the parts, and only left me two.
My options were: Deluxe Asus P9X79-WS, Asus X79 Rampage or ASRock Fatal1ty Champion,Gigabyte Ga-X79s- UP5
Any other options?
Hare 3930k OC without touching the voltage.
In thinking about the G.Skil RAM but it is 1.6 v ...
Please i need help.
My system:
Gigabyte GeForce GTX 670 OC 2GB GDDR5 http://www.pccomponentes.com/gigabyt...2gb_gddr5.html
Intel I7-3930K http://www.pccomponentes.com/intel_c...cket_2011.html
Corsair HX650 650W 80 Plus Gold http://www.pccomponentes.com/corsair...plus_gold.html
Noctua NH-D14 http://www.amazon.es/gp/product/B002...A1AT7YVPFBWXBL
Corsair 500R Carbide Series Blanca http://www.pccomponentes.com/corsair...es_blanca.html
Samsung 840 Pro SSD Series 256GB SATA3 Basic Kit http://www.pccomponentes.com/samsung...basic_kit.html
2x Seagate Barracuda 7200.14 1TB SATA3 http://www.pccomponentes.com/seagate...1tb_sata3.html
ThanksYou might go to the CS5 Benchmark http://ppbm5.com/ and see if there is a motherboard sort... I think ASUS is used more than either of the other two brands you mention
A note from Harm about ram http://forums.adobe.com/thread/1089842 -
C# Programming - I Need Help Putting a Loop into this Program!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Homework_2
class Program
static void Main(string[] args)
Console.WriteLine("Enter the First Value:");
var number1StringValue = Console.ReadLine();
Console.WriteLine("Enter the Second Value");
var number2StringValue = Console.ReadLine();
var number1 = Convert.ToDouble(number1StringValue);
var number2 = Convert.ToDouble(number2StringValue);
var sum = number1 + number2;
var difference = number1 - number2;
var product = number1 * number2;
var quotient = number1 / number2;
var remainder = number1 % number2;
Console.WriteLine("The Sum Is:");
Console.WriteLine(sum);
Console.WriteLine("The Difference Is:");
Console.WriteLine(difference);
Console.WriteLine("The Product Is:");
Console.WriteLine(product);
Console.WriteLine("The Quotient Is:");
Console.WriteLine(quotient);
Console.WriteLine("The Remainder Is:");
Console.WriteLine(remainder);
string answer;
Console.Write("Would You Like to Calculate More Numbers? Type: [Yes] or [No]");
answer = Console.ReadLine();
if (answer.Equals("Yes", StringComparison.InvariantCultureIgnoreCase))
Console.WriteLine("You Answered: Yes... The Program Will Continue");
Console.WriteLine("Not Really, I do not have enough knowledge to make this Program Loop, Sorry.");
Console.WriteLine("Press Any Key To Continue!");
Console.ReadKey();
// THIS IS WHERE I NEED THE PROGRAM TO LOOP AGAIN.
else if (answer.Equals("No", StringComparison.InvariantCultureIgnoreCase))
Console.WriteLine("You Answered: No... Press Any Key To Stop Program");
Console.ReadKey();
}static void Main(string[] args)
bool done = false;
while( !done )
Console.WriteLine("Enter the First Value:");
var number1StringValue = Console.ReadLine();
Console.WriteLine("Enter the Second Value");
var number2StringValue = Console.ReadLine();
var number1 = Convert.ToDouble(number1StringValue);
var number2 = Convert.ToDouble(number2StringValue);
var sum = number1 + number2;
var difference = number1 - number2;
var product = number1 * number2;
var quotient = number1 / number2;
var remainder = number1 % number2;
Console.WriteLine("The Sum Is:");
Console.WriteLine(sum);
Console.WriteLine("The Difference Is:");
Console.WriteLine(difference);
Console.WriteLine("The Product Is:");
Console.WriteLine(product);
Console.WriteLine("The Quotient Is:");
Console.WriteLine(quotient);
Console.WriteLine("The Remainder Is:");
Console.WriteLine(remainder);
string answer;
Console.Write("Would You Like to
Calculate More Numbers? Type: [Yes] or [No]");
answer = Console.ReadLine();
if (answer.Equals("Yes", StringComparison.InvariantCultureIgnoreCase))
Console.WriteLine("You
Answered: Yes... The Program Will Continue");
Console.WriteLine("Not
Really, I do not have enough knowledge to make this Program Loop, Sorry.");
Console.WriteLine("Press
Any Key To Continue!");
Console.ReadKey();
// THIS IS WHERE I NEED THE PROGRAM TO LOOP AGAIN.
else if (answer.Equals("No",
StringComparison.InvariantCultureIgnoreCase))
Console.WriteLine("You
Answered: No... Press Any Key To Stop Program");
Console.ReadKey();
done = true; -
I have an ipod touch 4th gen and when I plug it into my computer it shows up but it wont on iTunes and I was trying to put more music on it today and it wasn't showing up can u help please and thank you.
Hey Babetta94,
Thanks for using Apple Support Communities.
After reviewing your post, the iPod is not recognized in iTunes. A frustrating situation to be sure. You haven't mentioned what OS the computer you are using uses. You can choose what article to use either OS X or Windows from this quoted section.
iPod not appearing in iTunes
http://support.apple.com/kb/TS3716
If you have an iPod touch:
For Windows: See iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows
For Mac OS X: See iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X
Have a nice day,
Mario -
Need help in doing exercise with classes
Here is my exercise:
1. An object Student has: id, last name, first name, number of AAS courses and number of ESL courses in current semester and whether student uses laptop or not.
The formular to calculate tuition fee:
Tuition fee = AAS courses *20 ESL courses * +15+
+If student uses laptop, tuition fee will be deducted 5%
Write the methods to:
o Calculate tuition fee.
o Display student information
My Student class:
public class Student {
private String id;
private String lastName;
private String firstName;
private double nAAS;
private double nESL;
public void setIdentification(String input) {
id = input;
public void setLastName(String input) {
lastName = input;
public void setFirstName(String input) {
firstName = input;
public String getID() {
return id;
public String getLastName() {
return lastName;
public String getFistName() {
return firstName;
public void setNumberOfAAS(String input) {
nAAS = Double.parseDouble(input);
public void setNumberOfESL(String input) {
nESL = Double.parseDouble(input);
public double getNumberOfAAS() {
return nAAS;
public double getNumberOfELS() {
return nESL;
public double result(String input) {
if (input.equalsIgnoreCase("true")) {
return (getNumberOfAAS() * 20 + getNumberOfELS() * 15) * 0.95;
} else {
return getNumberOfAAS() * 20 + getNumberOfELS() * 15;
}And my DisplayResult class:
import javax.swing.JOptionPane;
public class DisplayResult {
public static void main(String[] args) {
String input;
Student st = new Student();
input = JOptionPane.showInputDialog("Enter the ID here:");
st.setIdentification(input);
input = JOptionPane.showInputDialog("Enter the last name:");
st.setLastName(input);
input = JOptionPane.showInputDialog("Enter the first name:");
st.setFirstName(input);
input = JOptionPane
.showInputDialog("Enter number of AAS courses you took:");
st.setNumberOfAAS(input);
input = JOptionPane
.showInputDialog("Enter number of ESL courses you took:");
st.setNumberOfESL(input);
input = JOptionPane
.showInputDialog("Enter \"true\" for using laptop and \"false\" if not:");
st.result(input);
// Display the result
JOptionPane.showMessageDialog(null, "The result is:\n" + st.getID()
+ " " + st.getLastName() + " " + st.getFistName()
+ "\nYou have: " + st.getNumberOfAAS() + " AAS "
+ st.getNumberOfELS() + " ESL\n" + "Using laptop: " + input
+ "\nYour tuitionFee is: "
+ st.result());
System.exit(0);
}The eclipse notice an error which is st.result in DisplayResult class. Please tell my what 's wrong with it?
Edited by: congtm88 on May 4, 2009 9:43 AMOh thax. I corrected it.
public static void main(String[] args) {
String input;
Student st = new Student();
input = JOptionPane.showInputDialog("Enter the ID here:");
st.setIdentification(input);
input = JOptionPane.showInputDialog("Enter the last name:");
st.setLastName(input);
input = JOptionPane.showInputDialog("Enter the first name:");
st.setFirstName(input);
input = JOptionPane
.showInputDialog("Enter number of AAS courses you took:");
st.setNumberOfAAS(input);
input = JOptionPane
.showInputDialog("Enter number of ESL courses you took:");
st.setNumberOfESL(input);
input = JOptionPane
.showInputDialog("Enter \"true\" for using laptop and \"false\" if not:");
// Display the result
JOptionPane.showMessageDialog(null, "The result is:\n" + st.getID()
+ " " + st.getLastName() + " " + st.getFistName()
+ "\nYou have: " + st.getNumberOfAAS() + " AAS "
+ st.getNumberOfELS() + " ESL\n" + "Using laptop: " + input
+ "\nYour tuitionFee is: "
+ st.result(input));
System.exit(0);
}But I think that, I should change result method into useOfLaptop then write one more instance method name getResult in Student class, right? -
Need help w/ for loop, a do loop, and a do-while loop.
Hello I have been trying to write a program that uses a for, do, and a do-while loop, but I am having trouble. I need the program that will prompt the user to enter two numbers. The first number must be less than the second number. I need to use a "for loop", a "do loop", and a "do-while loop" to display the odd numbers between the first number and the second number. For example, if the user entered 1 and 8, the program would display 3,5,7 three different times (one for each of the loops). Please help if you can. Thanks.
boolean2009 wrote:
Thank all of you all for responding.Youre welcome.
Yes this is my homework, but my major does not even involve java i just have to take the class.Not our problem.
And yes we are suppose to have all three in one program I do not know why,So you can learn all three types of loops (there is also an enhanced for loop to learn later on).
but I just do not understand programming nor do i really want to.Once again not our problem.
If anybody could help it would be much appreciated. thanks.Yes, a lot of people are willing to help you. No, none of them will do it for you. What you need to do is attempt the code and when you get stuck, post your code using the code button, include error messages, indicate which lines in your code genereate those error messages and ask specific questions. -
Need help with while loop and shift registers
I have a large data set and need to read in the data at maybe 200 samples at a time, process these samples through my VI, and have it append and concatenate a separate lvm file. The part where I am confused is the shift registers. How do I limit the number of samples read in an iteration? How do I get the while loop to stop when all the data are read in?
I've attached my diagram, maybe there is something wrong with my technique?
Solved!
Go to Solution.
Attachments:
shiftreg.JPG 56 KBThis will give you an idea. There are plenty of other (probably more efficient) methods. This is a basic, quick and dirty solution to help you grasp the overall concept.
Using LabVIEW: 7.1.1, 8.5.1 & 2013
Attachments:
ShiftRegLoop.JPG 54 KB
Maybe you are looking for
-
Display text in label from 'for loop'
Hi I'm new to Java, in fact so new just started yesterday. I'm trying to display all the values from a for loop into a label control in my application. Problem is, its only displaying the last number. Can anyone please help. Thanks George -----------
-
Dear Fellow, can u help me, i just buy some album from itunes 3 song of that album has "error downloading" statement, somehow i can't buy again the same song with this itunes. can i just delete that queqe song? thx
-
How do I authorize my pc to purchase songs from itunes store
Does anyone have information on how to authorize my pc through ITUNES store to redeem purchases?
-
On Startup: Open Document, Export as PDF (Print), Close
I'm a software developer but I've rarely worked in JavaScript-like languages. I have a simple task I'd like to automate. The task will run infrequently -- maybe a dozen times on a busy day -- so performance isn't a priority. My application generates
-
after update to ios7 on iphone 5 new iclouud terms and conditions must accept ther is error message unable to connect to server how can i solve this ?? with kind regards