Computer Science, asked by viraatas, 10 hours ago

How to Write a program that accepts the door number and street of the user and displays only the numbers present in the string in python

Answers

Answered by pratimadevigee
1

hope its works like and support

Attachments:
Answered by anjumanyasmin
1

From the given question the correct program is:

import java.util.Scanner;

public class Exercise38 {

   

public static void main(String[] args) {

 String test = " the door number  ";

 count(test);

}

public static void count(String x){

 char[] ch = x.toCharArray();

 int letter = 0;

 int space = 0;

 int num = 0;

 int other = 0;

 for(int i = 0; i < x.length(); i++){

  if(Character.isLetter(ch[i])){

   letter ++ ;

  }

  else if(Character.isDigit(ch[i])){

   num ++ ;

  }

  else if(Character.isSpaceChar(ch[i])){

   space ++ ;

  }

  else{

   other ++;

  }

 }

 System.oimport java.util.Scanner;

public class Exercise38 {

   

public static void main(String[] args) {

 String test = "  street of the user ";

 count(test);

}

public static void count(String x){

 char[] ch = x.toCharArray();

 int letter = 0;

 int space = 0;

 int num = 0;

 int other = 0;

 for(int i = 0; i < x.length(); i++){

  if(Character.isLetter(ch[i])){

   letter ++ ;

  }

  else if(Character.isDigit(ch[i])){

   num ++ ;

  }

  else if(Character.isSpaceChar(ch[i])){

   space ++ ;

  }

  else{

   other ++;

  }

 }

 System.out.println("The string is : Aa kiu, I swd skieo 236587. GH kiu: sieo?? 25.33");

 System.out.println("letter: " + letter);

 System.out.println("space: " + space);

 System.out.println("number: " + num);

 System.out.println("other: " + other);

  }

}ut.println("The string is : Aa kiu, I swd skieo 236587. GH kiu: sieo?? 25.33");

 System.out.println("letter: " + letter);

 System.out.println("space: " + space);

 System.out.println("number: " + num);

 System.out.println("other: " + other);

  }

}

Similar questions