Computer Science, asked by TheUntrustworthy, 1 month ago

Write this program in java​

Attachments:

Answers

Answered by anindyaadhikari13
6

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - Java.

import java.util.Scanner;

public class Java{

   public static void main(String s[]){

       Scanner sc=new Scanner(System.in);

       int n=50,i;

       double sales[]=new double[n];

       double cr[]=new double[n];

       double cd[]=new double[n];

       System.out.println("Enter monthly sales of 50 representatives.\n");

       for(i=0;i<n;i++){

           System.out.print("Enter sales of representative ["+(i+1)+"] = ");

           System.out.println("\n------------------------------------------------\n");

           if(sales[i]<=10000){

               cr[i]=5/100.0*sales[i];

               cd[i]=2/100.0*sales[i];

           }  

           else if(sales[i]<=20000){

               cr[i]=8/100.0*sales[i];

               cd[i]=3/100.0*sales[i];

           }

           else if(sales[i]<=30000){

               cr[i]=10/100.0*sales[i];

               cd[i]=4/100.0*sales[i];

           }

           else{

               cr[i]=12/100.0*sales[i];

               cd[i]=5/100.0*sales[i];

           }

       }

       sc.close();

       System.out.println("Sl. No.\tSale\tCommission of Representative\tCommission of Distribution");

       for(i=0;i<n;i++){

           System.out.println("     "+(i+1)+"\t"+sales[i]+"\t"+cr[i]+"\t\t\t\t"+cd[i]);

       }

   }

}

\textsf{\large{\underline{Logic}:}}

  • Accept the sales from the user and store the amounts in array.
  • Calculate the Commission of Representative and Distributor and store them in another array.
  • Use for loop to display the data in the given format.

anindyaadhikari13: Thanks for the Brainliest :)
Answered by ITZURADITYATYAKING
4

Answer:

\textsf{\large{\underline{Solution}:}}

Solution

:

The given problem is solved using language - Java.

import java.util.Scanner;

public class Java{

public static void main(String s[]){

Scanner sc=new Scanner(System.in);

int n=50,i;

double sales[]=new double[n];

double cr[]=new double[n];

double cd[]=new double[n];

System.out.println("Enter monthly sales of 50 representatives.\n");

for(i=0;i<n;i++){

System.out.print("Enter sales of representative ["+(i+1)+"] = ");

System.out.println("\n------------------------------------------------\n");

if(sales[i]<=10000){

cr[i]=5/100.0*sales[i];

cd[i]=2/100.0*sales[i];

}

else if(sales[i]<=20000){

cr[i]=8/100.0*sales[i];

cd[i]=3/100.0*sales[i];

}

else if(sales[i]<=30000){

cr[i]=10/100.0*sales[i];

cd[i]=4/100.0*sales[i];

}

else{

cr[i]=12/100.0*sales[i];

cd[i]=5/100.0*sales[i];

}

}

sc.close();

System.out.println("Sl. No.\tSale\tCommission of Representative\tCommission of Distribution");

for(i=0;i<n;i++){

System.out.println(" "+(i+1)+"\t"+sales[i]+"\t"+cr[i]+"\t\t\t\t"+cd[i]);

}

}

}

\textsf{\large{\underline{Logic}:}}

Logic

:

Accept the sales from the user and store the amounts in array.

Calculate the Commission of Representative and Distributor and store them in another array.

Use for loop to display the data in the given format.

Explanation:

BRO I REALLY REQUEST YOU CAN YOU PLEASE GIVE ME SOME THANKS PLEASE DON'T IGNORE ME PLEASE I WILL RETURN IT

Similar questions