01.11.2014, 16:35
I have Assignment that must be submitted by tomorrow, i was able to solve 4 of the 5 questions.
Well, i am stuck in this
and this what i did for now
Anyone knows how to solve it?
Well, i am stuck in this
Код:
Write a program that reads in from the user an integer (num) between 1000 and 9999. Then it prompts the user to enter an integer (d) between 0 and 9 and a character (ch). Your program should replace the second and the last digit in num with d and it should display the character that precedes (ch) followed by the number after the change and then the character that comes after (ch). Use the division and modulus operators to extract the digits from num. Sample run: Enter an integer between 1000 and 9999: 2134 Enter a digit (between 0 and 9): 6 Enter a character: b Number was 2134. Result: a2636c.
Код:
package question2; import java.util.Scanner; public class Question2 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter an integer between 1000 and 9999: "); int num = input.nextInt(); System.out.println("Enter a digit (between 0 and 9): "); int d = input.nextInt(); System.out.println("Enter a character: "); double ch = input.nextDouble(); } }