473,809 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cars program

9 New Member
[b]I need to finish this assignment can someone help me plz.

The Car Class


The purpose of this assignment is to learn how to write your own class that serves as a template for creating objects. The Car class represents an automobile. Each car has a color, miles driven, and the amount of gasoline in the tank (gallons).

The Car class should have both a default and parameterized constructor. The default constructor should initialize all of the instance variables. (The default miles driven and gallons should be zero.) The parameterized constructor will accept a color parameter. Each constructor should call the private method drawShape() that creates the car. (The car's shape does not need to be elaborate.)

Write the methods described here:

drawShape is a private method that creates the GCompound representing the car

setColor accepts a color parameter and sets the color of the car

drive accepts miles and speed as parameters. Miles must be greater than zero. Speed must be between 0 and 100. As long as the car has gas in the tank, add the miles to the car's total miles, and reduce the amount of gasoline based on the miles per gallon, which can be estimated using the following formula:
miles per gallon = 55 - speed/2

getMilesDriven returns the number of miles the car has driven

fill accepts an amount of gas as a parameter and adds it to the car's gallons; the amount must be greater than zero

isEmpty returns true if the car's tank is empty, and false if it is not

toString returns a String containing the car's miles driven and gallons in the tank




The UML class diagram for the Car class is displayed on the right. Do not create any instance variables or methods other than those shown.

To test your Car class, create an Applet called TestDrive that extends GraphicsProgram . Create and display three cars. Use each of your constructors at least once. Fill each tank and drive each car. Then, below each car, print its information using the toString() method. (Your cars do not need to move in this assignment.)

Sample output is shown here:



Have fun!


Car
_______________ _________
- color
- miles driven
- gallons
_______________ _________

+ Car()
+ Car(color)
- drawShape()
+ setColor(color)
+ drive(miles, speed)
+ getMilesDriven( )
+ fill(amount)
+ isEmpty()
+ toString()
Feb 22 '07
21 7672
r035198x
13,262 MVP
yes i have done this:

import java.util.*;
import java.text.*;
import java.awt.*;
import acm.graphics.*;

/*represents a car class*/
public class CAR extends GCompound
{
//declare instance variables//
private int gallons;
private boolean isEmpty;
private String toString;
private int fill;
private int drive;
private int MilesDriven;
private Color color;

/**Creates the defalut constructor*/
public CAR()
{
//Initialize instance variables
MilesDriven=0;
gallons=0;
color=Color.RED ;
toString=" ";
fill=0;
drive=0;

drawShape();
}

/**Creates the parameterized constructor*/
public CAR(int MilesDriven, int gallons, Color color)
{
//Initialize instance variables
this.MilesDrive n=MilesDriven;
this.gallons=ga llons;
this.color=colo r;

drawShape();
}

/**Sets how many gallons are needed*/
public void setGallons(int g)
{ gallons=g; }

/**Gets the gallons that we tell it to get.*/
public int getGallons()
{ return gallons; }

/**This method will return a boolean if the gas is empty.*/
public boolean isEmpty()
{
if (gallons <= 0)
{
return true;
}
else
{
return false;
}
}

/**This method will set how many miles and gallons are left.*/
public void setToString(Str ing string)
{
this.toString = string+MilesDri ven+gallons;
}

/**This method will tell us how many miles and gallons are left.*/
public String getToString()
{
return toString;
}

/**This method say to add the gallons to the car.*/
public void setFill(int amount)
{
if(amount>0)
{
amount += gallons;
}
}

/**This method will add the gallons to the car.*/
public int getFill()
{
return fill;
}

/**This method sets to how many miles the car has driven.*/
public void setMilesDriven( )
{
this.MilesDrive n=MilesDriven;
}

/**This method returns the number of miles the car has driven.*/
public int getMilesDriven( )
{
return MilesDriven;
}

/**This method will tell us the speed and miles the car has driven.*/
public void drive(double miles, int speed)
{
if(miles > 0)
{
miles += MilesDriven;

if(speed < 100)
{
MilesDriven=55-speed/2;
}
if(speed > 0)
{
//returns nothing//
}
}
}

/**This method will create the actual car and all of its parts*/
private void drawShape()
{
//Creates the top half of the car
GRect carsHead = new GRect(100, 100, 40, 40);
carsHead.setFil led(true);
carsHead.setFil lColor(color);
add(carsHead);

//Creates the bottom half of the car
GRect carsBottom = new GRect(100, 120, 60, 20);
carsBottom.setF illed(true);
carsBottom.setF illColor(Color. BLUE);
add(carsBottom) ;

//Creates the first window of the car
GRect firstWindow = new GRect(120, 105, 11, 11);
firstWindow.set Filled(true);
firstWindow.set FillColor(Color .WHITE);
add(firstWindow );

//Creates the second window of the car
GRect secondWindow = new GRect(102, 105, 11, 11);
secondWindow.se tFilled(true);
secondWindow.se tFillColor(Colo r.WHITE);
add(secondWindo w);

//Creates the first wheel of the car
GOval firstWheel = new GOval(105, 130, 20, 20);
firstWheel.setF illed(true);
firstWheel.setF illColor(Color. BLACK);
add(firstWheel) ;

//Creates the second window of the car
GOval secondWheel = new GOval(135, 130, 20, 20);
secondWheel.set Filled(true);
secondWheel.set FillColor(Color .BLACK);
add(secondWheel );
}
}


does this look correct??
You didn't have to post all the code. We can't compile and test that because we don't have the acm.graphics package that you are using (please you don't have to post it.)

What you should do is tell us how far you've got and what you now need help with. Are you getting any compile time errors, exceptions? Is the program doing what it is supposed to do?
Mar 1 '07 #11
javasomething
9 New Member
I fixed my indentation. there might be some false. And i have the applet at the bottom too.

Also how do I create an applet that simulates cars driving at differing speeds and displays the fuel cost for each car.


import java.util.*;
import java.text.*;
import java.awt.*;
import acm.graphics.*;

/*represents a car class*/
public class CAR extends GCompound
{
//declare instance variables//
private int gallons;
//private boolean isEmpty;
//private String toString;
//private int fill;
//private int drive;
private int milesDriven;
private Color color;

/**Creates the defalut constructor*/
public CAR()
{
//Initialize instance variables
milesDriven=0;
gallons=0;
color=Color.RED ;
// toString=" ";
//int fill;
// drive();

drawShape();
}

/**Creates the parameterized constructor*/
public CAR(int milesDriven, int gallons, Color color)
{
//Initialize instance variables
this.milesDrive n=milesDriven;
this.gallons=ga llons;
this.color=colo r;

drawShape();
}

/**Sets how many gallons are needed*/
public void setGallons(int g)
{ gallons=g; }

/**Gets the gallons that we tell it to get.*/
public int getGallons()
{ return gallons; }

/**This method will return a boolean if the gas is empty.*/
public boolean isEmpty()
{
if (gallons <= 0)
{
return true;
}
else
{
return false;
}
}

/**This method will set how many miles and gallons are left.*/
public void setToString(Str ing string)
{
String toString = " ";
toString = string+milesDri ven+gallons;
}

/**This method will tell us how many miles and gallons are left.*/
public String getToString()
{
return toString;
}

/**This method say to add the gallons to the car.*/
public void fill(int amount)
{
if(amount>0)
{
amount += gallons;
}
}

/*This method will add the gallons to the car.
public int getFill()
{
return fill;
}*/

/**This method sets to how many miles the car has driven.*/
public void setmilesDriven( )
{
this.milesDrive n=milesDriven;
}

/**This method returns the number of miles the car has driven.*/
public int getmilesDriven( )
{
return milesDriven;
}

/**This method will tell us the speed and miles the car has driven.*/
public void drive(double miles, int speed)
{
if(miles > 0)
{
miles += milesDriven;

if(speed < 100)
{
milesDriven=55-speed/2;
}
if(speed > 0)
{
//returns nothing//
}
}
}

/**This method will create the actual car and all of its parts*/
private void drawShape()
{
//Creates the top half of the car
GRect carsHead = new GRect(100, 100, 40, 40);
carsHead.setFil led(true);
carsHead.setFil lColor(color);
add(carsHead);

//Creates the bottom half of the car
GRect carsBottom = new GRect(100, 120, 60, 20);
carsBottom.setF illed(true);
carsBottom.setF illColor(Color. BLUE);
add(carsBottom) ;

//Creates the first window of the car
GRect firstWindow = new GRect(120, 105, 11, 11);
firstWindow.set Filled(true);
firstWindow.set FillColor(Color .WHITE);
add(firstWindow );

//Creates the second window of the car
GRect secondWindow = new GRect(102, 105, 11, 11);
secondWindow.se tFilled(true);
secondWindow.se tFillColor(Colo r.WHITE);
add(secondWindo w);

//Creates the first wheel of the car
GOval firstWheel = new GOval(105, 130, 20, 20);
firstWheel.setF illed(true);
firstWheel.setF illColor(Color. BLACK);
add(firstWheel) ;

//Creates the second window of the car
GOval secondWheel = new GOval(135, 130, 20, 20);
secondWheel.set Filled(true);
secondWheel.set FillColor(Color .BLACK);
add(secondWheel );
}
}


This is the applet:

import java.util.*;
import java.text.*;
import java.awt.*;
import acm.program.*;
import acm.graphics.*;
import java.awt.event. *;

/**Represents a car object*/
public class TestDrive extends GraphicsProgram
{
GLabel carLabel;

/**This method will draw the cars in the applet*/
public void run()
{
//Size of the applet//
setSize(800,600 );
//Add the MouseListeners events//
addMouseListene rs();

//First car from your left//
CAR c1 = new CAR(100,25,Colo r.RED);
add(c1, 20, 20);

//Second car in the middle//
CAR c2 = new CAR(235,26,Colo r.BLUE);
add(c2, 250, 20);

//Third car on your right//
CAR c3 = new CAR(456,20,Colo r.CYAN);
add(c3, 480, 20);
}

/**This method will show the gallons and miles when pressed on an object*/
public void mousePressed(Mo useEvent event)
{
Object obj = getElementAt(ev ent.getX(), event.getY());
if (obj instanceof CAR)
{
CAR car = (CAR)obj;
String text = car.getMilesDri ven() + " Miles and "
+ car.getGallons( ) + " gallons";
carLabel = new GLabel(text);
add(carLabel, event.getX(), event.getY());
}
}

/**This method will remove the label as soon as mouse has been released*/
public void mouseReleased(M ouseEvent event)
{
remove(carLabel );
}
}
Mar 5 '07 #12
r035198x
13,262 MVP
I fixed my indentation. there might be some false. And i have the applet at the bottom too.



Also how do I create an applet that simulates cars driving at differing speeds and displays the fuel cost for each car.





import java.util.*;

import java.text.*;

import java.awt.*;

import acm.graphics.*;



/*represents a car class*/

public class CAR extends GCompound

{

//declare instance variables//

private int gallons;

//private boolean isEmpty;

//private String toString;

//private int fill;

//private int drive;

private int milesDriven;

private Color color;



/**Creates the defalut constructor*/

public CAR()

{

//Initialize instance variables

milesDriven=0;

gallons=0;

color=Color.RED ;

// toString=\" \";

//int fill;

// drive();



drawShape();

}



/**Creates the parameterized constructor*/

public CAR(int milesDriven, int gallons, Color color)

{

//Initialize instance variables

this.milesDrive n=milesDriven;

this.gallons=ga llons;

this.color=colo r;



drawShape();

}



/**Sets how many gallons are needed*/

public void setGallons(int g)

{ gallons=g; }



/**Gets the gallons that we tell it to get.*/

public int getGallons()

{ return gallons; }



/**This method will return a boolean if the gas is empty.*/

public boolean isEmpty()

{

if (gallons <= 0)

{

return true;

}

else

{

return false;

}

}



/**This method will set how many miles and gallons are left.*/

public void setToString(Str ing string)

{

String toString = \" \";

toString = string+milesDri ven+gallons;

}



/**This method will tell us how many miles and gallons are left.*/

public String getToString()

{

return toString;

}



/**This method say to add the gallons to the car.*/

public void fill(int amount)

{

if(amount>0)

{

amount += gallons;

}

}



/*This method will add the gallons to the car.

public int getFill()

{

return fill;

}*/



/**This method sets to how many miles the car has driven.*/

public void setmilesDriven( )

{

this.milesDrive n=milesDriven;

}



/**This method returns the number of miles the car has driven.*/

public int getmilesDriven( )

{

return milesDriven;

}



/**This method will tell us the speed and miles the car has driven.*/

public void drive(double miles, int speed)

{

if(miles > 0)

{

miles += milesDriven;



if(speed < 100)

{

milesDriven=55-speed/2;

}

if(speed > 0)

{

//returns nothing//

}

}

}



/**This method will create the actual car and all of its parts*/

private void drawShape()

{

//Creates the top half of the car

GRect carsHead = new GRect(100, 100, 40, 40);

carsHead.setFil led(true);

carsHead.setFil lColor(color);

add(carsHead);



//Creates the bottom half of the car

GRect carsBottom = new GRect(100, 120, 60, 20);

carsBottom.setF illed(true);

carsBottom.setF illColor(Color. BLUE);

add(carsBottom) ;



//Creates the first window of the car

GRect firstWindow = new GRect(120, 105, 11, 11);

firstWindow.set Filled(true);

firstWindow.set FillColor(Color .WHITE);

add(firstWindow );



//Creates the second window of the car

GRect secondWindow = new GRect(102, 105, 11, 11);

secondWindow.se tFilled(true);

secondWindow.se tFillColor(Colo r.WHITE);

add(secondWindo w);



//Creates the first wheel of the car

GOval firstWheel = new GOval(105, 130, 20, 20);

firstWheel.setF illed(true);

firstWheel.setF illColor(Color. BLACK);

add(firstWheel) ;



//Creates the second window of the car

GOval secondWheel = new GOval(135, 130, 20, 20);

secondWheel.set Filled(true);

secondWheel.set FillColor(Color .BLACK);

add(secondWheel );

}

}





This is the applet:



import java.util.*;

import java.text.*;

import java.awt.*;

import acm.program.*;

import acm.graphics.*;

import java.awt.event. *;



/**Represents a car object*/

public class TestDrive extends GraphicsProgram

{

GLabel carLabel;



/**This method will draw the cars in the applet*/

public void run()

{

//Size of the applet//

setSize(800,600 );

//Add the MouseListeners events//

addMouseListene rs();



//First car from your left//

CAR c1 = new CAR(100,25,Colo r.RED);

add(c1, 20, 20);



//Second car in the middle//

CAR c2 = new CAR(235,26,Colo r.BLUE);

add(c2, 250, 20);



//Third car on your right//

CAR c3 = new CAR(456,20,Colo r.CYAN);

add(c3, 480, 20);

}



/**This method will show the gallons and miles when pressed on an object*/

public void mousePressed(Mo useEvent event)

{

Object obj = getElementAt(ev ent.getX(), event.getY());

if (obj instanceof CAR)

{

CAR car = (CAR)obj;

String text = car.getMilesDri ven() + \" Miles and \"

+ car.getGallons( ) + \" gallons\";

carLabel = new GLabel(text);

add(carLabel, event.getX(), event.getY());

}

}



/**This method will remove the label as soon as mouse has been released*/

public void mouseReleased(M ouseEvent event)

{

remove(carLabel );

}

}


Please, Please desist from posting all your code like this. It is not neccessary. If you really have to post any code do so using code tags. Now you are using a nonstandard graphics package acm.graphics. You will need to consult its API or help to be able to use it for your benefit.
Mar 5 '07 #13
javasomething
9 New Member
Ok I wont post the whole thing.

How do i Create an Applet that simulates cars driving at differing speeds and displays the fuel cost for each.
my simulation should display at least 3 cars. For each car, display the fuel cost and speed. Initially, your fuel cost for each car is zero. Drive one car at 50 MPH, one at 60 MPH, and one at 70 MPH.

I rellay need to finish this.

I need help fast plz. Can someone post the code for this. plz
Mar 5 '07 #14
r035198x
13,262 MVP
Ok I wont post the whole thing.

How do i Create an Applet that simulates cars driving at differing speeds and displays the fuel cost for each.
my simulation should display at least 3 cars. For each car, display the fuel cost and speed. Initially, your fuel cost for each car is zero. Drive one car at 50 MPH, one at 60 MPH, and one at 70 MPH.

I rellay need to finish this.

I need help fast plz. Can someone post the code for this. plz
No one is going to write the code for you. We are only here to assist not to do your homework for you. You need to design your applet first. How you are going to represent your cars. Whether you are going to use images e.t.c. The movement should not be too much of a problem. Just use threads for it and make sure the threads are pausing a time proportional to the speed of the cars.
Mar 6 '07 #15
javasomething
9 New Member
hello I am suppose to do this assignment can someone help me.

Shopping Cart

In this assignment, you will write an application to print receipts for purchases made at a store. The project consists of three classes:

1. The Item class represents an item that is for sale. An Item has a number, a name, and a price. For instance:

123, T-Shirt, $15.99

2. The Purchase class represents a customer's purchase of one or more Items. Each Purchase has a date, a subtotal, tax, and a number of items.

3. A driver class.

The UML class diagrams for Item and Purchase are shown here:

Item

- num
- name
- price
_______________ _

+ Item(num, name, price)
+ getNum
+ setName
+ getName
+ setPrice
+ getPrice
+ toString



Purchase

- Item[] items
- Date date
- subtotal
- tax
- numItems
+ TAX_RATE
- MAX_ITEMS
_______________ _

+ Purchase()
+ add(Item)
+ getSubtotal()
+ getTax()
+ total()
+ printReceipt()


In the Purchase class, initialize TAX_RATE to 0.086, and MAX_ITEMS to 100 in a static block. Then, write the methods shown in the diagram:

Purchase() Allocates memory for the items array to MAX_ITEMS

Initializes date to the current date
date = new Date();

Initializes subtotal, tax, total and numItems to zero



add(Item item): Checks to see if MAX_ITEMS is reached. If so, prints “Array is full.” Otherwise: Add new item to array at position numItems

Increment numItems

Adjust the subtotal to include the price of the new item

Adjust the tax to include the tax on the new item



getSubtotal(): returns subtotal


getTax(): returns tax


total(): returns total (subtotal plus tax)


printReceipt(): prints a summary of the purchase, including: “SALES RECEIPT"

date of purchase

a list of purchases, including item numbers, names and prices

the subtotal, tax, and total for the purchase, all formatted as currency.


write a driver class that contains a main method.

Instantiate at least three new items.

Create a new purchase

Add several items to the purchase

Print a receipt
Mar 11 '07 #16
r035198x
13,262 MVP
hello I am suppose to do this assignment can someone help me.

Shopping Cart

In this assignment, you will write an application to print receipts for purchases made at a store. The project consists of three classes:

1. The Item class represents an item that is for sale. An Item has a number, a name, and a price. For instance:

123, T-Shirt, $15.99

2. The Purchase class represents a customer's purchase of one or more Items. Each Purchase has a date, a subtotal, tax, and a number of items.

3. A driver class.

The UML class diagrams for Item and Purchase are shown here:

Item

- num
- name
- price
_______________ _

+ Item(num, name, price)
+ getNum
+ setName
+ getName
+ setPrice
+ getPrice
+ toString



Purchase

- Item[] items
- Date date
- subtotal
- tax
- numItems
+ TAX_RATE
- MAX_ITEMS
_______________ _

+ Purchase()
+ add(Item)
+ getSubtotal()
+ getTax()
+ total()
+ printReceipt()


In the Purchase class, initialize TAX_RATE to 0.086, and MAX_ITEMS to 100 in a static block. Then, write the methods shown in the diagram:

Purchase() Allocates memory for the items array to MAX_ITEMS

Initializes date to the current date
date = new Date();

Initializes subtotal, tax, total and numItems to zero



add(Item item): Checks to see if MAX_ITEMS is reached. If so, prints “Array is full.” Otherwise: Add new item to array at position numItems

Increment numItems

Adjust the subtotal to include the price of the new item

Adjust the tax to include the tax on the new item



getSubtotal(): returns subtotal


getTax(): returns tax


total(): returns total (subtotal plus tax)


printReceipt(): prints a summary of the purchase, including: “SALES RECEIPT"

date of purchase

a list of purchases, including item numbers, names and prices

the subtotal, tax, and total for the purchase, all formatted as currency.


write a driver class that contains a main method.

Instantiate at least three new items.

Create a new purchase

Add several items to the purchase

Print a receipt
Start a new thread for this one and give it a title that best describes your problem
Mar 12 '07 #17
javasomething
9 New Member
I need to finish this assignment can somone do it by tommorrow 9:00 AM plz



Shopping Cart

In this assignment, you will write an application to print receipts for purchases made at a store. The project consists of three classes:

1. The Item class represents an item that is for sale. An Item has a number, a name, and a price. For instance:

123, T-Shirt, $15.99

2. The Purchase class represents a customer's purchase of one or more Items. Each Purchase has a date, a subtotal, tax, and a number of items.

3. A driver class.

The UML class diagrams for Item and Purchase are shown here:

Item

- num
- name
- price
_______________ _____

+ Item(num, name, price)
+ getNum
+ setName
+ getName
+ setPrice
+ getPrice
+ toString



Purchase

- Item[] items
- Date date
- subtotal
- tax
- numItems
+ TAX_RATE
- MAX_ITEMS
_______________ _

+ Purchase()
+ add(Item)
+ getSubtotal()
+ getTax()
+ total()
+ printReceipt()







In the Purchase class, initialize TAX_RATE to 0.086, and MAX_ITEMS to 100 in a static block. Then, write the methods shown in the diagram:

Purchase() Allocates memory for the items array to MAX_ITEMS

Initializes date to the current date
date = new Date();

Initializes subtotal, tax, total and numItems to zero



add(Item item): Checks to see if MAX_ITEMS is reached. If so, prints “Array is full.” Otherwise: Add new item to array at position numItems

Increment numItems

Adjust the subtotal to include the price of the new item

Adjust the tax to include the tax on the new item



getSubtotal(): returns subtotal


getTax(): returns tax


total(): returns total (subtotal plus tax)


printReceipt(): prints a summary of the purchase, including: “SALES RECEIPT"

date of purchase

a list of purchases, including item numbers, names and prices

the subtotal, tax, and total for the purchase, all formatted as currency




For help with formatting, see Java's printf command. A sample "receipt" is shown here:



Now, write a driver class that contains a main method.

Instantiate at least three new items.

Create a new purchase

Add several items to the purchase

Print a receipt


Generate an API for your Item class using the javadoc utility.
Include Item.html in your folder when you submit the assignment.
You do not need to print it out.
Mar 15 '07 #18
r035198x
13,262 MVP
I need to finish this assignment can somone do it by tommorrow 9:00 AM plz



Shopping Cart

In this assignment, you will write an application to print receipts for purchases made at a store. The project consists of three classes:

1. The Item class represents an item that is for sale. An Item has a number, a name, and a price. For instance:

123, T-Shirt, $15.99

2. The Purchase class represents a customer's purchase of one or more Items. Each Purchase has a date, a subtotal, tax, and a number of items.

3. A driver class.

The UML class diagrams for Item and Purchase are shown here:

Item

- num
- name
- price
_______________ _____

+ Item(num, name, price)
+ getNum
+ setName
+ getName
+ setPrice
+ getPrice
+ toString



Purchase

- Item[] items
- Date date
- subtotal
- tax
- numItems
+ TAX_RATE
- MAX_ITEMS
_______________ _

+ Purchase()
+ add(Item)
+ getSubtotal()
+ getTax()
+ total()
+ printReceipt()







In the Purchase class, initialize TAX_RATE to 0.086, and MAX_ITEMS to 100 in a static block. Then, write the methods shown in the diagram:

Purchase() Allocates memory for the items array to MAX_ITEMS

Initializes date to the current date
date = new Date();

Initializes subtotal, tax, total and numItems to zero



add(Item item): Checks to see if MAX_ITEMS is reached. If so, prints “Array is full.” Otherwise: Add new item to array at position numItems

Increment numItems

Adjust the subtotal to include the price of the new item

Adjust the tax to include the tax on the new item



getSubtotal(): returns subtotal


getTax(): returns tax


total(): returns total (subtotal plus tax)


printReceipt(): prints a summary of the purchase, including: “SALES RECEIPT"

date of purchase

a list of purchases, including item numbers, names and prices

the subtotal, tax, and total for the purchase, all formatted as currency




For help with formatting, see Java's printf command. A sample "receipt" is shown here:



Now, write a driver class that contains a main method.

Instantiate at least three new items.

Create a new purchase

Add several items to the purchase

Print a receipt


Generate an API for your Item class using the javadoc utility.
Include Item.html in your folder when you submit the assignment.
You do not need to print it out.
Read this .
Mar 15 '07 #19
javasomething
9 New Member
All right i wont print anymore homework. But i have some questions:

What is a class member?
What is the difference between a do loop and a while loop?
What is the difference between a static and instance variables?
Write a statement to declare a char variable c and assign it the value X.

Thanks
Mar 18 '07 #20

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

Similar topics

22
3615
by: edgrsprj | last post by:
PROPOSED EARTHQUAKE FORECASTING COMPUTER PROGRAM DEVELOPMENT EFFORT Posted July 11, 2005 My main earthquake forecasting Web page is: http://www.freewebz.com/eq-forecasting/Data.html Newsgroup Readers: If you circulate copies of this report to groups of computer programmers at different universities etc. around the world then they might find the subject matter to be interesting.
0
6146
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
11
2615
by: christopher diggins | last post by:
I am wondering if any can point me to any open-source library with program objects for C++ like there is in Java? I would like to be able to write things like MyProgram1 >> MyProgram2 >> Fork(MyProgram3, SomeFile); If not would this be something of interest to others? Thanks in advance,
1
3278
by: Eric Whittaker | last post by:
hi all, im trying to write my first c++ program. a success, but i can't get the window to stay open after user enters input. it just automatically closes. right now the end of my program looks like this: return 0; }
9
4541
by: Hemal | last post by:
Hi All, I need to know the memory required by a c program. Is there any tool/utility which can give me the memory usage in terms of DATA segment, TEXT segment, BSS segment etc. I am working on linux platform and my target is ARM processor. But i guess it should not matter. Actually i need to know both RAM & ROM usage.
0
1390
by: mambonumba1 | last post by:
There have been many efforts to innovate automobile design funded by the NHTSA, including the work of the NavLab group at Carnegie Mellon University. Recent efforts include the highly publicized DARPA Grand Challenge race. Relatively high transportation fuel prices do not significantly reduce car usage but do make it more expensive. One environmental benefit of high fuel prices is that it is an incentive for the production of more...
7
13272
by: ibtc209 | last post by:
I just started programming in C, and I need some help with this problem. Your program will read the information about one MiniPoker hand, namely the rank and suit of the hand’s first card, and the rank and suit of its second card. Note that the two cards in a hand may be entered in any order; it’s not necessarily the case that the highest card will appear first, for example. Your program will then determine whether the hand is valid, and...
2
19357
Banfa
by: Banfa | last post by:
Posted by Banfa The previous tutorial discussed what programming is, what we are trying to achieve, the answer being a list of instructions constituting a valid program. Now we will discuss how we set about doing that. Every program starts with a specification, this may be a several hundred page document from your latest client or one small paragraph from your professor and pretty much anything in-between. The specification is very...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10637
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.