Menu
Question Index
...

Write a program to convert mobile to XML.

Input(NumberOfSims, Maker, Model, CameraMegaPixels) Output(XML String)
NumberOfSims = 1, Maker = "Nokia", Model = "3412", CameraMegaPixels = 2.5 <Mobile><NumberOfSims>1</NumberOfSims><Maker>Nokia</Maker><Model>3412</Model><CameraMegaPixels>2.5</CameraMegaPixels></Mobile>
NumberOfSims = 2, Maker = "Samsung", Model = "2252", CameraMegaPixels = 1.2 <Mobile><NumberOfSims>2</NumberOfSims><Maker>Samsung</Maker><Model>2252</Model><CameraMegaPixels>1.2</CameraMegaPixels></Mobile>
NumberOfSims = 2, Maker = "Apple", Model = "C3752", CameraMegaPixels = 12.0 <Mobile><NumberOfSims>2</NumberOfSims><Maker>Apple</Maker><Model>C3752</Model><CameraMegaPixels>12.0</CameraMegaPixels></Mobile>



class ConvertMobileToXML
{
    public static void main(String s[])
    {
        Mobile mobeen_mobile = new Mobile(1, "Nokia", "3412", 2.5);
        System.out.println("Converted XML is : " + convertToXML(mobeen_mobile));

    }


    public static String convertToXML(Mobile mobile) {
    String result = null;
    return result;
    }

}
class Mobile {

int numberOfSims;
String maker;
String model;
double cameraMegaPixels;

public Mobile(int numberOfSims, String maker, String model, double cameraMegaPixels) {
this.numberOfSims = numberOfSims;
this.maker = maker;
this.model = model;
this.cameraMegaPixels = cameraMegaPixels;
}
}

Doubts

Problems

Topic: this Keyword In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App