Computer Science, asked by abhijitdey16122004, 1 month ago

PLEASE SOLVE AND SEND ME THE SOLUTION
WANT THE SOLUTION FROM YOUR COPY
please do it in scanner class

Attachments:

Answers

Answered by anindyaadhikari13
6

\texttt{\textsf{\large{\underline{Question 1}:}}}

Hint: Use escape sequence (non graphic characters).

The Co‎‎de:

public class Fruits{

   public static void main(String s[]){

       System.out.println("Apple.\nMango.\nGrapes.\nGuava.\nStrawberry.");

   }

}

\texttt{\textsf{\large{\underline{Question 2}:}}}

Hint: Calculate the difference between SP and CP.

The Co‎‎de:

public class Profit{

   public static void main(String s[]){

       double SP=10000.0,CP=7000.0,P,PP;

       System.out.println("SP: Rs. "+SP);

       System.out.println("CP: Rs. "+CP);

       P=SP-CP;

       PP=P/CP * 100;

       System.out.println("Gain: Rs. "+P);

       System.out.println("Gain Percentage: "+PP+"%");

   }

}

Attachments:
Answered by kamalrajatjoshi94
1

Answer:

Program 1:-

import java.util.*;

public class Main

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

System.out.println("Apple"+"\n"+"Mango"+"\n"+"Grapes"+"\n"+"Water Melon"+"\n"+"Strawberry");

in.close();

}

}

Program 2:-

import java.util.*;

public class Main

{

public static void main(String args[])

{

Scanner in=new Scanner(System.in);

int cp=7000,sp=10000,p=0;

double pp=0;

p=sp-cp;

pp=p/(double)cp*100;

System.out.println("The profit="+p);

System.out.println("The profit percent="+pp+"%");

in.close();

}

}

Output is attched.

I did it in scanner class but I didn't used it as you didn't asked to input

Formula:-

P=SP-CP

profit%=p/cp*100

Attachments:
Similar questions