The program must accept a character representing the mobile signal .
– If the character is E, print 2G
– If the character is H, print 3G
– Else print 4G
Python
ch = input()
if ch == 'E':
print('2G')
elif ch == 'H':
print('3G')
else:
print('4G')
Java
import java.util.*;
public class Hello {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char ch = sc.next().charAt(0);
if (ch == 'E') {
System.out.print("2G");
} else if (ch == 'H') {
System.out.print("3G");
} else {
System.out.print("4G");
}
}
}
C
#include <stdlib.h>
#include <stdio.h>
int main()
{
char ch;
scanf("%c", &ch);
if(ch == 'E'){
printf("2G");
}
else if(ch == 'H'){
printf("3G");
}
else{
printf("4G");
}
}
C++
#include <iostream>
using namespace std;
int main()
{
char ch;
cin >> ch;
if(ch == 'E')
{
cout << "2G";
}
else if(ch == 'H')
{
cout << "3G";
}
else
{
cout << "4G";
}
return 0;
}
Leave a Reply