Medicine App Problem Solution in Java | Capgemini ADAPT Solution 2022 using Java

Medicine App Problem Solution in Java | Capgemini ADAPT Solutions 2022
Medicine App Problem Solution in Java | Capgemini ADAPT Solutions 2022

In this post, you will get the solution to the Capgemini ADAPT 2022 solution to the problem Medicine App in Java. Capgemini ADAPT Java Solutions 2022, Medicine App.

Note: The solutions are provided for learning purposes only. 

Table of Contents

Medicine App Problem Description:


Create an abstract class Medicine to represent a drug manufactured by a pharmaceutical company. Provide a method label() in this class to print the Name and Address of the company.

Derive Tablet, Syrup and Ointment classes from the Medicine class.

Override the label() method in each of these classes to print additional information suitable to the type of medicine.

For example,

in the case of tablets, it could be “store in a cool dry place”,

in the case of ointment, it could be “for external use only”

and in the case of syrup, it could be “Store it in a dry place”

method signature

void label(String CompanyName.String Address)

Capgemini ADAPT 2022 – Medicine App Problem Solution in Java:


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

abstract class Medicine 
{ 
public void label(String CompanyName, String Address) 
{ 
System.out.println("Company Name:"+CompanyName); 
System.out.println("Address:"+Address); 
} 
} 
class Ointment extends Medicine{
public void label(String CompanyName, String Address) 
{ 
System.out.println("Company Name:"+CompanyName);
System.out.println("Company Address:"+Address);
 System.out.println("for external use only");
 } 
} 
class Syrup extends Medicine{
 public void label(String CompanyName,String Address) 
{ 
System.out.println("Company Name:"+CompanyName);
 System.out.println("Company Address:"+Address);
 System.out.println("Store it in a dry place");
 } 
} 
class Tablet extends Medicine{
 public void label(String CompanyName,String Address)
 { 
System.out.println("Company Name:"+CompanyName);
 System.out.println("Company Address:"+Address); 
System.out.println("store in a cool dry place");
 } 
} 
public class Source 
{ 
public static void main(String[] args)
{ 
String CompanyName="Himalaya Syrup"; 
String Address="Bangalore"; 
Scanner sc=new Scanner(System.in); 
int choice=sc.nextInt(); 
if(choice==3) 
{ 
for(int i=0;i<4;i++)
 { 
Tablet t=new Tablet();
 t.label(CompanyName,Address);
 }
} else if(choice==2) 
{ 
for(int i=0;i<4;i++) 
{ 
Ointment o=new Ointment();
 o.label(CompanyName,Address);
 } 
} else if(choice==1) 
{ 
for(int i=0;i<4;i++) 
{ 
Syrup s=new Syrup();
 s.label(CompanyName,Address);
 } 
}
 else { 
System.out.println("invalid input");
 } 
} 
}

 

TOP COMPANIES HIRING DRIVE

BATCHWISE OFF-CAMPUS DRIVES

1. TCS OFF-CAMPUS DRIVES1. 2018 BATCH
2. INFOSYS OFF-CAMPUS DRIVES2. 2019 BATCH
3. COGNIZANT OFF-CAMPUS DRIVES3. 2020 BATCH
4. WIPRO OFF-CAMPUS DRIVES4. 2021 BATCH
5. CAPGEMINI OFF-CAMPUS DRIVES5. 2022 BATCH

 

To Stay Up-to-date, Follow us on Social Media:


1.      Join our Telegram Channel:

Click Here

2.      Like us on Facebook:

Click Here

3.      Follow us on Instagram:

Click Here

4.      Follow us on LinkedIn:

Click Here

5.      Follow us on Google News:

Click Here

 

ADAPT Different Coding Solutions:


  1. Largest Array Solution – Click Here
  2. Batsman & Bowler Solution – Click Here
  3. Medicine App Problem Solution – Click Here
  4. Check Two Person Are Same – Click Here
  5. Medicine App ADAPT Solution – Click Here

Capgemini ADAPT Sprint 1 (Bus Reservation Solutions):


Capgemini ADAPT Sprint 2 (Bus Reservation System):


Study Materials for Interview Preparation (FREE MATERIALS):


  1. 240 Core Java Questions & Answers with PDF Download Link – Click Here
  2. 230+ SQL interview questions & answers pdf download – Click Here
  3. 50 LeetCode Interview Questions with Answers – PDF Notes – Click Here 
Previous articleInstruments Problem Solution in Java | Capgemini ADAPT Solutions 2022
Next articleString Combinations Problem Solution in Java | Capgemini ADAPT Solution using Java
Job Seeker 24 provides Off-Campus Drive Updates, Engineering Job Updates, IT Job Updates, Jobs for Freshers, Private Sector Jobs, Public Sector Jobs, various Educational Opportunities, etc.