A
A
AidanaEnver2018-04-03 17:25:00
Java
AidanaEnver, 2018-04-03 17:25:00

I can't understand what is the error (math.min(), math.max())?

//help please
import java.lang.Math;
import java.util.Scanner;
public class d {
public static void main(String[] args) {
int an;
Scanner sc = new Scanner(System.in);
System.out.println("vvedite c");
int c = sc.nextInt();
System.out.println("vvedite b");
int b = sc.nextInt();
an= 12 * Math.max(c,b) + Math.min(2*c,b-1);
return;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Burtsev, 2018-04-13
@voksus

It looks like you are not familiar with Java.
The logic is not very clear, but try this code:

import java.util.Scanner;

public class D {

    public static void main(String[] args) {
        int an;
        Scanner sc = new Scanner(System.in);

        System.out.println("vvedite c");
        int c = sc.nextInt();

        System.out.println("vvedite b");
        int b = sc.nextInt();

        an= 12 * Math.max(c,b) + Math.min(2*c,b-1);
    }
}

For the future, class names are always (!) capitalized.
I will keep silent about obvious garbage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question