Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I received this error when i tried the program in command prompt, when used javac, not sure why? this is the file, I am

I received this error when i tried the program in command prompt, when used javac, not sure why?

 

this is the file, I am trying to run for Java in the command prompt.

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class A2MI4609437 program using a loop {
public static void main(String[] args)
throws IOException {
Scanner scanner = new Scanner(System.in);
FileWriter writer = new FileWriter("output.txt");
try{
int firstNum, secondNum;
while (true) {
System.out.print("Enter the first number (positive integer):");
firstNum = scanner.nextInt();
System.out.print("Enter the second number (at least 10 greater than the first, less than 1000): ")
secondNum = scanner.nextInt();
if (firstNum > 0 && secondNum >= firstNum + 10 && secondNum < 1000 {
break;
} else {
System.out.println("Invalid input. Please try again.");
}
}
writer.write(Odd Numbers:\n")
for (int i = firstNum; i <= secondNum; i++) {
if (i % 2 != 0){
writer.write(i + "\n");
              }
          }
int sum = 0;for (int i = firstNum + 1; i < secondNum; i++) {
sum += i;
          }
writer.write("Sum of Numbers (Exclusive):\n");
writer.write(sum + "\n");
writer.write("Numbers in Reverse Order:\n");
for (int i = secondNum; i >= firstNum; i--) {
writer.write(i);
if (i != firstNum) {
writer.write(", ");
              }
          }
writer.write("\n");

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
writer.write("Date and Time:\n");
writer.write(LocalDateTime.now().format(formatter) + "\n");

} finally {
scanner.close();
writer.close();
      }
  } 


error: Class names, 'A2MI4609437', are only accepted if annotation processing is explicitly requested 1 error

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

1119563097, 9781119563099

More Books

Students also viewed these Algorithms questions

Question

(0, 2) Plot the given points in a coordinate system.

Answered: 1 week ago

Question

A clubs general manager performs what types of duties? AppendixLO1

Answered: 1 week ago