Java Assignment Help.
#8

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
I program in java so here is solution -
Код:
package question2;
import java.util.Scanner;

public class Question2 {
   
  void main() {

    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: ");
    char ch = input.nextLine.charAt(0);//thats how u enter a char
    String result = (ch-1);//it stores the final result
    int r,c = 1,f=num;
    while(num != 0)
    {
       r = num % 10;
       num = num/10;
      if(c==2 || c==4)result+=d;
      else result+=r;
      c++;
    }
    result+= (ch+1);
    System.out.println("Number was "+f+". Result : "+result);
 
        
   }
    
}
didnt tested it caz currently i dont have bluej on my pc
But should work...
First of all, handing him a clear cut solution is NOT helping. He will learn nothing from it and, depending on how strict his school is, could even get in trouble for handing in code that isn't his.

Furthermore, it doesn't work...


@OP:
In Java, a String cannot be modified. However, you can convert the string to a array of characters (******, in which you can modify each individual character.
Reply


Messages In This Thread
Java Assignment Help. - by ColonelBurton - 01.11.2014, 16:35
Re: Java Assignment Help. - by Mauzen - 01.11.2014, 17:09
Re: Java Assignment Help. - by ColonelBurton - 01.11.2014, 19:15
Re: Java Assignment Help. - by IvanSb - 01.11.2014, 19:34
Re: Java Assignment Help. - by RaZVaN ^ xD - 02.11.2014, 00:28
Re: Java Assignment Help. - by Mauzen - 02.11.2014, 00:52
Re: Java Assignment Help. - by BroZeus - 02.11.2014, 08:07
Re: Java Assignment Help. - by Infinity - 02.11.2014, 08:17
Re: Java Assignment Help. - by BroZeus - 02.11.2014, 08:37
Re: Java Assignment Help. - by Infinity - 02.11.2014, 10:28

Forum Jump:


Users browsing this thread: 2 Guest(s)