Answer to Question #231643 in Java | JSP | JSF for Subhu

Question #231643
In a bank there are two types of transactions: credit and debit. All transactions are assigned an alphabetical ID. Credit transactions are assigned a vowel and debit transactions are assigned a consonant. To track transactions over a year, all the transaction IDs are combined to form a string of IDs for each customer. A customer wishes to know the number of times he made a debit transaction immediately after a credit transaction.

Write an algorithm to print the count of debit transactions that were made immediately afte a credit transaction for that particular customer.

Input

The first line of the input consists of a string userString, representing the string of transaction IDs.

Output

Print an integer representing the count of det transactions made immediately after a credit
1
Expert's answer
2021-08-31T23:52:13-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		String creditID;
		String debitID;
		Scanner in=new Scanner(System.in);
		int count=0;
		System.out.println("Enter credit transaction id: ");
		creditID=in.next();
		System.out.println("Enter debit transaction id: ");
		debitID=in.next();
		String s=creditID+debitID;
		System.out.println(s);
		
		for(int i = 0; i < s.length(); i++) {    
            if(s.charAt(i) != ' ')    
                count++;    
        }
        System.out.println("Count= " + count);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS