Question

In: Computer Science

This code assigns the maximum of the values 3 and 5 to the int variable max...

This code assigns the maximum of the values 3 and 5 to the int variable max and outputs the result

int max;

// your code goes here

This code prompts the user for a single character and prints "true" if the character is a letter and "false" if it is not a letter

// your code goes here

Solutions

Expert Solution

mport java.util.*;
public class Letter
{
   public static void main(String args[])
   {
       Scanner sc = new Scanner(System.in);
       int max;
       int var1 = 3;
       int var2 = 5;
       if(var1 > var2)
       {
           max = var1;
       }
       else
       {
           max = var2;
       }
       System.out.println("maximum number is : "+max);
      
       System.out.println("enter a character:");
       char ch = sc.next().charAt(0);
       if(ch >=65 && ch<=90 || ch >= 97 && ch <= 122)
       {
           System.out.println("true\n");
       }
       else
       {
           System.out.println("flase\n");
       }
   }
}

If you have any doubts please comment and please don't dislike


Related Solutions

The following pseudocode finds the maximum element in an array of size n. Int MAX (int...
The following pseudocode finds the maximum element in an array of size n. Int MAX (int A [ ], int n) { M = A[0]; for i = 1 to n – 1     if (A[i] > M)         M = A[i]        //Update the max return M; } Write a recursive version of this program. Let f(n) be the number of key comparisons performed by this algorithm. Write a recurrence equation for f(n). Prove by induction that the solution of...
// 1. System.out.println("1."); int max = 5; for (int n = 1; n <= max; n++)...
// 1. System.out.println("1."); int max = 5; for (int n = 1; n <= max; n++) { System.out.println(n); } System.out.println(); // 2. System.out.println("2."); int total = 25; for (int number = 1; number <= (total / 2); number++) { total = total - number; System.out.println(total + " " + number); } System.out.println(); // 3. System.out.println("3."); for (int i = 1; i <= 2; i++) { for (int j = 1; j <= 3; j++) { for (int k = 1;...
Write a program/code that prompts the user for a minimum min and a maximum max. Then...
Write a program/code that prompts the user for a minimum min and a maximum max. Then use these values to print the squares of all even numbers between the min and max variables. (WRITTEN IN C) For example if the user enters 6 as the minimum and 200 as the maximum, the program/code should print the following. Enter limit on minimum square: 6 Enter limit on maximum square: 200 36 64 100 144 196
Write a C program/code that prompts the user for a minimum min and a maximum max....
Write a C program/code that prompts the user for a minimum min and a maximum max. Then use these values to print the squares of all even numbers between the min and max variables. For example if the user enters 6 as the minimum and 200 as the maximum, the program/code should print the following. Enter limit on minimum square: 6 Enter limit on maximum square: 200 36 64 100 144 196
Write code that finds the largest number in data and stores it in the variable max...
Write code that finds the largest number in data and stores it in the variable max and the smallest number in data and stores it in min. Test Cases Test case #1 Expected result: max is 52.66; min is 15.53 Test case #2 Expected result: max is 56.95; min is 5.77 Test case #3 Expected result: max is 77.02; min is 24.24 Test case #4 Expected result: max is 90.48; min is 35.94.
int main() {    footBallPlayerType bigGiants[MAX];    int numberOfPlayers;    int choice;    string name;   ...
int main() {    footBallPlayerType bigGiants[MAX];    int numberOfPlayers;    int choice;    string name;    int playerNum;    int numOfTouchDowns;    int numOfcatches;    int numOfPassingYards;    int numOfReceivingYards;    int numOfRushingYards;    int ret;    int num = 0;    ifstream inFile;    ofstream outFile;    ret = openFile(inFile);    if (ret)        getData(inFile, bigGiants, numberOfPlayers);    else        return 1;    /// replace with the proper call to getData    do    {       ...
The maximum allowable tensile force in the members of the truss is (Ft) max = 5 kN
Problem 6.26 The maximum allowable tensile force in the members of the truss is (Ft) max = 5 kN, and the maximum allowable compressive force is (Fc)max = 3.4 kN. (Figure 1) Part A Determine the maximum magnitude P of the two loads that can be applied to the truss. Express your answer to three significant figures and include the appropriate units.
My current code that is not working correctly #include<stdio.h> #include<math.h> int main() { //variable declaration int...
My current code that is not working correctly #include<stdio.h> #include<math.h> int main() { //variable declaration int a,b,c,D,n; double x1,x2; double realPart, imagPart; do { // this set of code blocks prompts a message to the user and then read the integer entered and stores it as an integer printf("Enter a value for a:\n"); scanf("%d",&a); printf("Enter a value for b:\n"); scanf("%d",&b); printf("Enter a value for c:\n"); scanf("%d",&c); printf("You entered the Equation \n"); printf("%dx^2%+dx%+d=0\n",a,b,c); D = b*b - 4*a*c;    if (D<0)...
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5,...
QUESTION 5 What is printed? int[] aArray = {1, 2, 3, 4}; int[] bArray = {5, 6, 7, 8}; bArray = aArray; System.out.print(bArray[2]); 1 points    QUESTION 6 What is printed? public static void main(String[] args) { int[] aArray = { 1, 2, 3, 4 }; System.out.print(aArray[2]); int i = aMeth(aArray); System.out.print(i + "" + aArray[2]); } public static int aMeth(int[] iArray) { for (int i = 0; i < iArray.length; i++) { iArray[i]++; } int[] bArray = { 5,...
#include <stdio.h> #define MAX 8 //Byte = 8 bits void func_and(int a[], int b[], int result[])...
#include <stdio.h> #define MAX 8 //Byte = 8 bits void func_and(int a[], int b[], int result[]) { for(int i=0; i < MAX; i = i + 1){ result[i] = a[i] & b[i]; } } void func_or(int a[], int b[], int result[]) { for(int i=0; i < MAX; i = i + 1){ result[i] = a[i] || b[i]; } } void func_not(int a[], int result[]) { for (int i = 0; i < MAX; i = i + 1) { result[i]...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT