Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Java Programming

Featured Replies

I'm currently taking a Java programming class in college. I have the following 2 problems that I just can not figure out.

 

1. Given two variables number and lsd of type int, write an expression that assigns the least significant digit of number of lsd. For example, if number is 567, then lsd should get a value of 7.

 

and

 

1. Given two variables number and secondDigit of type int, write a code fragment so that the variable secondDigit gets the second digit (from right) of number. For example, if number is 56487, then secondDigit should get a value of 8. [Remark: You are allowed to write multiple Java statements. However, there is a way to achieve this by just one Java statement. ]

 

I have searched and have gotten nowhere. If someone would be able to at least guide me in the right direction I'll be able to handle the rest.

 

Thanks!

 

EDIT: I'm not asking for anyone to do it for me, I'm just asking for something so I'll be able to figure it out.

 

EDIT2: I figured out the first one.

[hide]

public class numberfive {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int number;
int lsd;

number = 567;
lsd = number%10;

System.out.println("Least Significant Digit = " + lsd);


}
}

[/hide]

Finally on here to update that I have officially quit! It's been fun.
[hide=Signature]
Gandalf14141.png
R.I.P Billy Mays and <3 My Friend C.D.S 7/8/09 <3
60,816th to 99 Fletching 03/07/09|220,309th Person to be Able to Kill Dusties 10 Year Cape on 12/20/14[/hide]

grammar2gr8dx.png

  • Author

Ah. Thank you very much! That makes sense! I was stumped so I was hoping someone would be willing to help on here.

Finally on here to update that I have officially quit! It's been fun.
[hide=Signature]
Gandalf14141.png
R.I.P Billy Mays and <3 My Friend C.D.S 7/8/09 <3
60,816th to 99 Fletching 03/07/09|220,309th Person to be Able to Kill Dusties 10 Year Cape on 12/20/14[/hide]

grammar2gr8dx.png

  • 2 months later...

I'm currently taking a Java programming class in college. I have the following 2 problems that I just can not figure out.

 

1. Given two variables number and lsd of type int, write an expression that assigns the least significant digit of number of lsd. For example, if number is 567, then lsd should get a value of 7.

 

and

 

1. Given two variables number and secondDigit of type int, write a code fragment so that the variable secondDigit gets the second digit (from right) of number. For example, if number is 56487, then secondDigit should get a value of 8. [Remark: You are allowed to write multiple Java statements. However, there is a way to achieve this by just one Java statement. ]

 

I have searched and have gotten nowhere. If someone would be able to at least guide me in the right direction I'll be able to handle the rest.

 

Thanks!

 

EDIT: I'm not asking for anyone to do it for me, I'm just asking for something so I'll be able to figure it out.

 

EDIT2: I figured out the first one.

[hide]

public class numberfive {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int number;
int lsd;

number = 567;
lsd = number%10;

System.out.println("Least Significant Digit = " + lsd);


}
}

[/hide]

Ah. Thank you very much! That makes sense! I was stumped so I was hoping someone would be willing to help on here.

 

You could also get the length/count and extract the number that way.

Have an Android phone? Check out my Runescape apps:

https://play.google.com/store/apps/developer?id=SAA

 

 

Follow my app development Twitter here.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.