Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MAKE SURE YOU USE CONDITIONALS FOR 1.A AND WHILE LOOPS FOR 1.B. IF YOU DON\'T, I

ID: 3601804 • Letter: M

Question

MAKE SURE YOU USE CONDITIONALS FOR 1.A AND WHILE LOOPS FOR 1.B. IF YOU DON'T, IT WILL BE FLAGGED FOR REVIEW.

Make sure you input comments and formatting, please. These are must Use conditionals for 1.A and while loops for 1.B, please. These are must Answer both 1 . A and 1. B and incorrect answers or incomplete work will be flagg 1A. for a review. Write a Java program that prompts the user to enter in two countries. The program then prints out which country has more letters or if they have the same number of letters, the first character of both countries, and if the countries entered are the same. Test the program with two sets of data (one showing the cities have different number of characters and one showing that they have the same number of letters) The program works as follows: Enter two cities: Halifax Bedford Halifax and Bedford have the same number of letters The first character of Halifax is H. The first character of Bedford is B Halifax and Bedford are not the same city. 1.B Write a complete program that will use a Scanner to ask for the total marks for your tests, assignments and labs each as a percentage (out of 100). If the lab mark is higher than the assignments the lab mark is omitted and the tests are weighted at 60% and the assignments at 40%. Otherwise the tests are weighted at 50% the assignments at 40% and the labs at 10%. The program then computes and prints your final grade as a letter. If you get 80% or higher the letter grade is an A, 70 or higher is a B, 60 or higher a C, 50 or higher a D and less than 50 a F. Test the program with two sets of data and include the results in this report that show both outcomes for the final grade calculation (with two different letter grades).

Explanation / Answer

Please note that chegg allows us to answer for only the first question if multiple questions are present.

Thus, I can only answer for 1A.

I hope you sort this out with the chegg community :D

The answer to the 1A part is as follows.

import java.util.Scanner; // needed for Scanner

/** A Java program that demonstrates console based input and output. */
public class firstjava
{
        // Create a single shared Scanner for keyboard input
   private static Scanner scanner = new Scanner( System.in );

        // Program execution starts here
   public static void main ( String [] args )
   {
            // Prompt the user
       System.out.print( "Enter two cities: " );

            // Read words of text from the user.
       String city1 = scanner.next(), city2 = scanner.next();

            // Display the output back to the user.
       if(city1.length() > city2.length())
           System.out.println(" " + city1 + " has more number of letters. ");
       else if(city1.length() < city2.length())
           System.out.println(" " + city2 + " has more number of letters. ");
       else
           System.out.println(" " + city1 + " " + city2 + " have the same number of letters. ");

       System.out.println("First character of " + city1 + " is " + city1.charAt(0) + ". First character of " + city2 + " is " + city2.charAt(0) + ". ");

       if(city1.equals(city2))
           System.out.println(city1 + " and " + city2 + " are the same city." + " ");
       else
           System.out.println(city1 + " and " + city2 + " are not the same city."+ " ");
      
    } // end main method
}