1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LenKa [72]
3 years ago
10

Write code to print the location of any alphabetic character in the 2-character string passCode. Each alphabetic character detec

ted should print a separate statement followed by a newline. Ex: If passCode is "9a", output is: Alphabetic at 1 Hint: Use two if statements to check each of the two characters in the string, using Character.isLetter().
Computers and Technology
1 answer:
serg [7]3 years ago
5 0

Answer:

// here is code in java.

import java.util.*;

//class defintion

class Main

{

// main method of class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object to read input

       Scanner s=new Scanner(System.in);

       String passcode;

       System.out.print("please enter the passcode:");

       // read string from user

       passcode=s.nextLine();

       // find first character

       char ch=passcode.charAt(0);

       // find second character

       char ch1=passcode.charAt(1);

       // if first character is alphabet

       if(Character.isLetter(ch))

       System.out.println("Alphabetic at 0:");

       // if second character is alphabet  

      else if(Character.isLetter(ch1))

       System.out.println("Alphabetic at 1:");

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create a scanner class object to read input from user.Read 2-character string

from user.Find the each character and check if it is a alphabet or not.If First

character is alphabet then print "Alphabetic at 0:" else if second character

is alphabet then print "Alphabetic at 1:".

Output:

please enter the passcode:b2

Alphabetic at 0:

You might be interested in
Write a static method named evenNumbers that accepts a string of text as a parameter. Assume that the text is a series of intege
Allisa [31]

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Import input/output and utility libraries

import java.io.*;

import java.util.*;

Declare class/

public class Numbers {

// Main method goes here

public static void main(String[] args) throws FileNotFoundException

{

// Read input from text file evenFile.txt; Assume file name is evenFile.txt

Scanner input = new Scanner(new File("evenFile.txt"));

// Call static method here

evenNumbers(input);

}

// Static method evenNumbers begins here

public static void evenNumbers(Scanner input)

{

// Declare and initialise Variables

String Nums = input.nextLine(); // Read all number in txt file

Scanner numbers = new Scanner (Nums);

int count = 0; // Number count

int evens = 0; // Even count

int sum = 0; // Summation of numbers

// Check if number is integer. If yes, continue the below operations

while (numbers.hasNextInt())

{

int num = numbers.nextInt();

count++;

sum = sum + num;

if(num % 2 == 0) // check for even

{

evens++;

}

}

System.out.println("Total numbers= " + count); // Print total number

System.out.println("Sum of numbers = " + sum); // Print summation of numbers

System.out.println("Total evens = " + evens); // Print total even

//Calculate and print percentage of even number

double percent = ((double)evens/count)*100.0);

System.out.println("Percent of even number = " +percent);

}

}

// End of program

8 0
3 years ago
Read 2 more answers
he is trying to find information on the internet first he navigated to a search engine entered the keywords database administrat
Vlada [557]

Answer:

b

Explanation:

b

6 0
3 years ago
Need help finding the totals and with the empty spots
Lunna [17]

Answer:

weff WEF ef ef aeF EFaef  EFE  fe efaef ea f

Explanation:

8 0
3 years ago
What is a feature of Print Preview?
Snezhnost [94]
Fit to page i believe
6 0
3 years ago
Explain each kind of pointer and for what it is appropriate.
Mademuasel [1]

Pointer: A pointer is a variable which holds the address of other variable of the specified data type(like int,float,char). In programming we basically use pointers to store the other variable's address.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Is it bad to leave a co2 cartridge in an airsoft pistol?
    6·2 answers
  • When investigators find evidentiary items that aren't specified in a warrant or under probable cause what type of doctrine appli
    8·1 answer
  • 3. Which one of the following statements is true for spell checkers?
    11·1 answer
  • Assume that two arrays are parallel. Assume the first array contains a person's id number and the second contains his or her age
    5·1 answer
  • What is the difference between a switch and a hub?
    8·1 answer
  • Question 1: An acronym is a word formed by taking the first letters of the words in a phrase and making a word from them. For ex
    14·1 answer
  • Who is Mr.Anonymous?
    5·2 answers
  • Where is the option to set Conditional Formatting rules found?
    6·1 answer
  • In a DTP project, Fiona is looking for a way to make a page layout attractive to readers. Help Fiona pick the correct word to co
    10·1 answer
  • Briefly describe the function of options in a linux command and give an example of a useful option.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!