• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes
86 views

Problem:

Write an expression to detect that the first character of user input matches first letter.

by (720 points)  
retagged by

1 Answer

0 votes

Resolution:

First Program

import java.util.Scanner;

public class DetectFirstChar {

public static void main (String [] args) {

String input = "";

char fletter = '-';

input = "mango";

firstLetter = 'm';

if  {

System.out.println("Found match: " + fletter );

}

else {

System.out.println("No match: " + fletter );

}

return;

}

}

Second Program

#include

#include

using namespace start;

int main() {

string input;

char fletter = ‘-‘;

userInput = “mango”;

firstLetter = ‘m’;

if (fLetter = input.at(0)) {

cout << "Found match: " << fLetter << endl; } else { cout << "No match: " << fLetter<< endl; } return 0; }

by (4k points)  
edited by
...