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
mamaluj [8]
3 years ago
9

Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not

following that format is incorrect and should be ignored. Use the substring() method to parse the string and extract the date. The input ends with -1 on a line alone. Output each correct date as: 3/1/1990. Ex: If the input is:
Computers and Technology
1 answer:
rewona [7]3 years ago
8 0

Answer:

Explanation:

The following code was written in Java it creates a switch statement for all the month values in order to turn them from Strings into integer values. Then it reads every line of input places them into an array of dates if they are the correct input format, and loops through the array changing every date into the correct output format.Ouput can be seen in the attached picture below.

import java.util.ArrayList;

import java.util.Scanner;

class Brainly {

   public static int intForMonth(String monthString) {

       int monthValue;

       switch (monthString) {

           case "January": monthValue = 1;

               break;

           case "February": monthValue = 2;

               break;

           case "March": monthValue = 3;

               break;

           case "April": monthValue = 4;

               break;

           case "May": monthValue = 5;

               break;

           case "June": monthValue = 6;

               break;

           case "July": monthValue = 7;

               break;

           case "August": monthValue = 8;

               break;

           case "September": monthValue = 9;

               break;

           case "October": monthValue = 10;

               break;

           case "November": monthValue = 11;

               break;

           case "December": monthValue = 12;

               break;

           default: monthValue = 00;

       }

       return monthValue;

   }

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       ArrayList<String> dates = new ArrayList<>();

       String date;

       String month;

       String day;

       String year;

       int i = 0;

       while (true) {

           date = scnr.nextLine();

           if (date.equals("-1")) {

               break;

           }

           dates.add(date);

       }

       for (i = 0; i < dates.size(); i++) {

           try {

               month = dates.get(i).substring(0, dates.get(i).indexOf(" "));

               day = dates.get(i).substring(dates.get(i).indexOf(" ") + 1, dates.get(i).indexOf(","));

               year = dates.get(i).substring(dates.get(i).indexOf(",") + 2, dates.get(i).length());

               System.out.println(intForMonth(month) + "/" + day + "/" + year);

           } catch (Exception e) {}

       }

   }

}

You might be interested in
I'm very confused about this, I am seeing multiple different answers and I thought the answer was obvious, but guess not.
BabaBlast [244]
I NEED POINTSSS if you understand I just don’t know the answer sorry
6 0
3 years ago
Read 2 more answers
Suppose that you need to access a data file named "students.txt" to hold student names and GPAs. If the user needs to look at th
pogonyaev

Answer:

f = open('students.txt', 'r')

Explanation:

In the computing world, a command is an instruction to a computer program to execute a particular task. These instructions might be issued via a command-line interface, such as a shell program, or as a input to a network service as a component of a network protocol, or can be instructed as an event in a graphical user interface activated by the respective user selecting an option in a menu.

the f = open('students.txt', 'r') command line would be used to open a file named "students.txt", There are also various other types of commands for executing different task, for example:

1. ASSOC for Fix File Associations

2. FC for File Compare

3. IPCONFIG for IP Configuration

4. NETSTAT for Network Statistics

5. PING for Send Test Packets

6. TRACERT for Trace Route

7. POWERCFG for Power Configuration

e.t.c.

5 0
3 years ago
Is this website real? Or is it a scam?
nikitadnepr [17]

It's a scam don't buy something

5 0
3 years ago
Which of the following is preventing the remote user from being able to access the workstation?
larisa86 [58]

Answer:

Option C is the correct option to the following question.

Explanation:

In the following statement, the absence of the network time simultaneous occurrence is generated by the authentication mismatches then, the remote user is preventing access to the workstations. So that's why the network time is absent that caused the prevention in the remote user by accessing the workstations.

5 0
4 years ago
Consider a network of 8 routers connected together to provide more than one path of connectivity between host A and host B at tw
ser-zykov [4K]

Answer:

Option C is the correct option to the following question

Explanation:

Because there are not any limits is required of sending data and packets between host A and host B by the routers and the router permit more than one paths between the hosts for the establishment of the connectivity st two distinct locations in the routing protocol. The router transmits the packets between the hosts that is produced by link-state protocol.

5 0
3 years ago
Other questions:
  • More Loops: All versions of foods.py in this section have avoided using for loops when printing to save space. Choose a version
    13·1 answer
  • Write a C function check(x, y, n) that returns 1 if both x and y fall between 0 and n-1 inclusive. The function should return 0
    6·1 answer
  • Match the file extensions to the file types. Some file types may be used more than once.
    11·1 answer
  • The difference between a checked and an unchecked exception is:
    10·1 answer
  • Which of the following was (and still is) used by computer programmers as a first test program?
    13·2 answers
  • Information has just been sent from a Web form on a client's system to a Web server. Which of the following is required to proce
    14·1 answer
  • Research the significance of the UNIX core of macOS and write a few sentences describing your findings.
    8·1 answer
  • PLZ PLZ PLZ PLZ HELP will mark brainlist What component contains the ROM (Read Only Memory)?
    5·1 answer
  • What are the differences between switches and routers? cse question
    8·1 answer
  • C code
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!