Ccs332 App Dev Lab Manual Aiml
Ccs332 App Dev Lab Manual Aiml
Name :
Roll. No :
Year :
Semester :
Subject :
Branch :
GOJAN SCHOOL OF BUSINESS AND TECHNOLOGY
Approved by AICTE & Affiliated to Anna University Chennai
NAAC Accredited Institution
Recognized by UGC u/s 2(f) & 12 (B) of the UGC Act
EDAPALAYAM, REDHILLS, CHENNAI – 600 052
BONAFIDE CERTIFICATE
Name :
Department :
Roll No :
Register No.
Certified that this is the bonafide record of work done by the above student in the
Laboratory during the year 20 – 20 .
Aim:
To develop a cross-platform BMI (Body Mass Index) calculator application using React
Native, capable of running on both iOS and Android devices.
Body Mass Index (BMI) is a number calculated from a person's weight and height that helps
determine if they are underweight, normal weight, overweight, or obese.
Procedure
Step 1: Install Required Tools:
a) Install Node.js
Programme Implementation
Step 6: Open bmi_calculator/src/App.js and type code
setBmi(bmiValue.toFixed(2));
} else {
setBmiCategory('Obese');
}
};
return (
<View style={styles.container}>
<Text style={styles.title}>BMI Calculator</Text>
<TextInput
style={styles.input}
placeholder="Weight (kg)"
keyboardType="numeric"
value={weight}
onChangeText={setWeight}
/>
<TextInput
style={styles.input}
placeholder="Height (cm)"
keyboardType="numeric"
value={height}
onChangeText={setHeight}
/>
<Button title="Calculate BMI" onPress={calculateBMI} />
{bmi && (
<View>
<Text style={styles.result}>Your BMI:{bmi}</Text>
<Text style={styles.result}>Category: {bmiCategory}</Text>
</View>
)}
</View>
);
}
},
title: {
fontSize: 24,
fontWeight: 'bold',
textAlign: 'center',
marginBottom: 20,
},
input: {
borderWidth: 1,
borderColor: 'gray',
borderRadius: 5,
padding: 10,
marginBottom: 10,
},
result: {
fontSize: 18,
textAlign: 'center',
marginTop: 20,
},
});
Result :
BMI calculator App is built by the React native Cross Platform Framework.
Date -
Exercise:2 Develop a cross platform application to convert units from imperial system
to metric system (km to miles , kg to pounds etc.,)
Aim
To develop a cross-platform application for unit conversion from the imperial system to the
metric system, by using React Native Framework. This framework allows us to write code
once and deploy it on multiple platforms such as iOS, Android, and web.
Procedure
Step 1 - Set up your development environment: Install Node.js, npm (Node Package
Manager), and the chosen framework (React Native or Flutter) on your machine.
npm install convert-units
Step 2 - Create a new project: Use the command-line interface to create a new project using
the framework's CLI tool. For example, with React Native, use the command
npx create-react-app UnitConverter.
Step 3 - Design the user interface: Use the framework's components and layout system to
design the user interface for your unit converter application. Use text inputs for user input and
labels to display the converted values.
Step 4 - Implement the conversion logic: Write the code to convert units from the imperial
system to the metric system. For example, to convert kilometers to miles, you can use the
conversion formula miles = kilometers * 0.621371. Implement similar conversion formulas
for other unit conversions.
Step 5 - Handle user input: Capture user input from the text inputs and trigger the conversion
logic when the user submits the form or presses a button.
Step 6 - Display the converted values: Update the labels or text fields with the converted
values based on the user input and the conversion logic.
Step 7 - Test the application: Run the application on different platforms (iOS, Android, web)
to ensure it works correctly and displays the converted values accurately.
Programme Implementation
Step 1: Setup your IDE. (Visual studio code is recommended.)
a) Install the plugins Live Server, babel JavaScript, Prettier – code and Es7 – react* in
Vs code
setResult(convertedValue.toFixed(2));
} catch (error) {
};
return (
<View style={styles.container}>
<Text>Unit Converter</Text>
<TextInput
style={styles.input}
keyboardType="numeric"
value={inputValue}
onChangeText={setInputValue}
placeholder="Enter value"
/>
{/* Add pickers or dropdowns for selecting fromUnit and toUnit */}
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 6,
// justifyContent: 'center',
alignItems: 'center',
marginLeft: -1100,
padding: 20,
},
input: {
borderWidth: 1,
borderColor: 'graykl',
padding: 10,
marginBottom: 10,
width: 200,
},
result: {
fontSize: 18,
marginTop: 10,
},
});
Result :
A cross Platform Application is build which converts units from imperial system to
metric system.
Date -
Exercise : 3
Build a cross-platform application for a simple expense manager which allows entering
expenses and income on each day and displays category wise weekly income and
expense.
Aim : To build a cross-platform application fusing Flutter Framework for a simple expense
manager which allows entering expenses and income on each day and displays category wise
weekly income and expense
Procedure
Step1:
Create APP: Android Studio, and create a new Flutter Give the project name
"expense today”. And click. Next and follow the same to use the default settings.
Step 2: Now delete all the code from the main.dart file.
main.dart
import 'package:flutter/material.dart';
final String appTitle = "Expense App";
void main() {
runApp(ExpenseApp());
}
class ExpenseApp extends Stateless Widget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: appTitle,
theme: ThemeData(
primarySwatch: Colors.green,
visualDensity: VisualDensity.adaptivePlatformDensity, ),
home: Text(appTitle),
debugShowCheckedModeBanner: false);
}}
Step 4: Run the app:
main.dart file at the bottom after Expense App class, write the Following code.
class HomeScreen extends StatefulWidget {
constHomeScreen( ({Key key}): super(key: key);
@override
_HomeScreenStatecreateState() =>_HomeScreenState();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: ListView(
children: [
Text("ABC"),
Text("DEF"),
],
),
),
appBar: AppBar(
title: Text(title),
),
floating ActionButton: Pressed: () {}, Floating ActionButton.extended(
onPressed : ( ) { },
label: Text('Add'),
icon: Icon(Icons.add),
backgroundColor: Colors.pink,
),
);
}}
Step 6: Update ExpenseApp Widget
class ExpenseApp extends Stateless Widget {
//
This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
…
home: HomeScreen(),
…
}
Step 7: Fix Test Code red line is showing under the widget_test.dart. To remove it just
change MyApp() to Expense App()
Step:9 Creating the Widget UI. write the following code in the category_widget.dart file
@override
_Category WidgetStatecreateState() => _CategoryWidgetState();
}
class_CategoryWidgetState extends State<CategoryWidget> {
@override
Widget build(BuildContext context) {
return Card(
child: Padding(
padding: constEdgeInsets.all(15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.space Between, children: [
Padding(
child: Text(
"$(widget.rowNumber + 1}",
style: TextStyle(
fontSize: 20,
font Weight: Font Weight.bold,
),
),
),
Expanded(
child: TextField(
onChanged: (text) {
print(text);
},
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Category',
),
),
),
Icon(Icons.attach_money),
Expanded(
child: TextField(
onChanged: (text) {
print(text);
},
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Cost',
),
),
],
),
),
),
}
}
Step 10: Update the ListView within the class. _HomeScreenstate
class_HomeScreenState extends State<HomeScreen> {
@override
body: SafeArea(
child: ListView(
children: [
Category Widget(
rowNumber: 0,
callback: () {},
),
Category Widget(
rowNumber: 1,
callback: () {},
),
],
),
),
…
);
}
}
void addRow() {
setState(() {
totalRow+1:
});}...)
return Scaffold(
body: SafeArea(
child: ListView(
children: [
for (int i = 0; i<totalRow; ++i)
Category Widget(
rowNumber: i,
callback: () {}, ), ], ),
),
],
),
),
Step 14: onPressed function of the floating ActionButton widget and add a reference of
addRow function.
…
floatingActionButton: Floating ActionButton.extended(
onPressed: addRow,
label: Text('Add'),
icon: Icon(Icons.add),
backgroundColor: Colors.pink,
),
…
Step 15: save the file to hot reload the app. You see, the app screen is blank, and if
you click + Add continuously a new Category Widget will be added within the ListView.
Now update the main.dart file by importing the new widget here.
import package:expense_today/category_widget.dart';
callback: () {},
),
Category Widget(
rowNumber: 1,
callback: () {},
),
],
),
),
…
);
}}
Within the ListView you remove the old Text widgets and adds 2 CategoryWidget. You
also pass rowNumber:0 for the first one and rowNumber: 1 for the second one. Currently the
callback function is empty.
A user will click the pink +Add button new row will be added. To do that, let's add int
totalRow = 0; within the HomeScreenState
totalRow += 1;
});
}
…
List View within the_HomeScreenWidget again: {
return Scaffold(
body: SafeArea(
child: ListView(
children: [
),
],
),
),
...
floating ActionButton: FloatingActionButton.extended(
onPressed: _addRow,
label: Text('Add'),
icon.Icon(Icons.add),
background Color:Colors.pink,
),
…
.
Result :
A cross-platform Application for a simple expense manager is built which allows
entering expenses and income.
Date -
Exercise:4
Design and develop a Cross platform application for day to day task (to-do)
management.
Aim
The aim of this project is to design and develop a cross-platform task management
application using React Native that enables users to efficiently create, manage, and track their
daily to-do tasks. The application will allow users to:
Add new tasks.
Mark tasks as complete or incomplete.
Categorize tasks.
Store tasks locally for persistence between app sessions using AsyncStorage.
This project aims to provide a simple, user-friendly interface for managing personal or work-
related tasks, ensuring users can keep track of their daily responsibilities across Android, iOS,
and Web platforms.
Procedure
Step 1: Install Required Tools:
d) Install Node.js
Step 6: Add Data Persistence Using AsyncStorage to Install AsyncStorage to persist task data
even after the app is closed, run the below command in Vscode Terminal
useEffect(() => {
loadTasks();
}, []);
useEffect(() => {
saveTasks();
}, [tasks]);
}
};
} catch (e) {
console.log(e);
}
};
setTask('');
}
};
));
};
return (
<View style={styles.container}>
<FlatList
data={tasks}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={styles.taskItem}>
<Text
style={{
textDecorationLine: item.completed ? 'line-through' : 'none'
}}
>
{item.name}
</Text>
<Button
title={item.completed ? 'Undo' : 'Complete'}
</View>
)}
/>
</View>
);
};
flex: 1,
padding: 20,
backgroundColor: '#f5f5f5'
},
title: {
fontSize: 24,
fontWeight: 'bold',
marginBottom: 20
},
input: {
borderWidth: 1,
borderColor: '#ccc',
padding: 10,
marginBottom: 20,
borderRadius: 5
},
taskItem: {
flexDirection: 'row',
justifyContent: 'space-between',
padding: 15,
backgroundColor: '#fff',
borderBottomWidth: 1,
borderBottomColor: '#eee'
}
});
Aim:- Program to design an android application using Cordova for a user login screen with
username, password, reset button and a submit button. Also, include header image and a
label. Use layout managers.
Theory: The aim of the program is to develop an Android application using Cordova
framework, featuring a user login screen. The login screen includes input fields for
username and password, along with buttons for resetting the form and submitting the
login details. Additionally, the application incorporates a header image and a label for
visual appeal. Layout managers are utilized to organize the elements on the screen
efficiently, ensuring a user-friendly interface.
Procedure:
Set Up Cordova Project: Ensure Cordova is installed, then create a new project
with cordova create.
Add Android Platform: Add the Android platform to the project using cordova
platform add android.
Design User Interface: Create an HTML file (index.html) for the login screen layout,
including input fields for username and password, along with reset and submit buttons.
Utilize CSS for styling.
Build and Run: Build the Cordova project using cordova build android, then run it on an
Android device or emulator using cordova run android.
Test: Test the application to ensure the login screen functions as expected, allowing
users to input their credentials and submit the form.
Code
cd UserLoginApp
Create your HTML file with the login screen layout. You can use CSS for styling.
<head>
<meta charset="utf−8" />
<meta name="viewport" content="width=device−width, initial−scale=1"
/>
<title>User Login</title>
<link rel="stylesheet" type="text/css" href="css/index.css" />
</head>
<body>
<div class="header">
<img src="header_image.png" alt="Header Image" />
<h1>Login</h1>
</div>
<div class="container">
<form id="loginForm">
<label for="username">Username:</label>
<input type="text" id="username" name="username" />
<label for="password">Password:</label>
<input type="password" id="password" name="password" />
<script src="js/index.js"></script>
</body>
</html>
Css:
/* css/index.css */ body {
font−family: Arial, sans−serif;
}
.header {
text−align: center;
}
.container {
margin: 20px auto; width: 80%;
}
label {
display: block; margin−bottom: 5px;
}
input {
width: 100%; padding: 8px;
margin−bottom: 10px;
}
button {
padding: 10px; margin−top: 10px;
}
JavaScript Functionality:
// js/index.js
function resetForm() { document.getElementById("loginForm").reset();
}
function onDeviceReady() {
// Get the elements
const usernameField = document.getElementById('username');
const passwordField = document.getElementById('password');
const submitButton = document.getElementById('submitButton');
const resetButton = document.getElementById('resetButton');
cordova build
cordova run android
Result :
An Android Application is built using Cordova for a user login screen with username
and password.
Date -
Exercise : 6
Design and develop an android application using Apache Cordova to find and display
the current location of the user.
Aim : To develop an android application using Apache Cordova to find and display the
current location of the user.
Procedure
Step 1 - Install Apache Cordova:
Run the following command to install Cordova globally:
npm install -g cordova
Step 2 - Create a New Cordova Project
In the terminal, create a new Cordova project using the following commands:
cordova create LocationApp com.example.locationapp LocationApp
cd LocationApp
Step 3 - Install the Geolocation Plugin
To access the device's location, install the Cordova geolocation plugin:
cordova plugin add cordova-plugin-geolocation
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-
scalable=no" />
<title>Location App</title>
</head>
<body>
<h1>Find My Location</h1>
<button onclick="getLocation()">Get Location</button>
<div id="locationOutput"></div>
<script type="text/javascript">
function getLocation() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
}
// onSuccess Geolocation
function onSuccess(position) {
}
// onError Callback
function onError(error) {
document.getElementById('locationOutput').innerHTML = 'Error: ' +
error.message;
}
</script>
</body>
</html>
Step 6 - Build the Application
Run the following command to build the application for Android:
cordova build android
Run the Application on an Android Device
To run the app on a connected Android device or emulator, execute:
cordova run android
Result :
An Android Application is built using Cordova to find and display the current location
of user.
Date -
Exercise 7:
Design and implement a simple library management system using a switch statement in
java, where following operations are operated - Add a new classes', check out a book,
display specific book status, search specific book status and display book details using
different classes
Aim : To design and implement a simple Library Management System in Android using
Java and a switch statement for controlling operations, we can use Android Studio to create
the app which uses multiple classes that perform the following operations:
Procedure:
Step 1 - Project Setup
Open Android Studio and create a new project with an Empty Activity.
Name the project LibraryManagementSystem.
This class will manage the library’s operations, such as adding books, checking out, and
displaying statuses.
Create LibraryManager.java:
import java.util.ArrayList;
public LibraryManager() {
bookList = new ArrayList<>();
}
if (book.getTitle().equalsIgnoreCase(title)) {
book.displayDetails();
return;
}
}
System.out.println("Book not found.");
}
}
}
}
package com.example.librarymanagementsystem;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
@Override
libraryManager.displayBookStatus(bookTitle);
Toast.makeText(this, "Displaying Book Status", Toast.LENGTH_SHORT).show();
break;
case 4:
android:gravity="center">
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Library Management System"
android:textSize="24sp"
android:layout_marginBottom="20dp"/>
<Button
android:id="@+id/btnAddBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<Button
android:id="@+id/btnCheckoutBook"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<Button
android:id="@+id/btnDisplayStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<Button
android:id="@+id/btnShowAllBooks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show All Books"
android:layout_marginTop="10dp"/>
</LinearLayout>
You will see the main screen with buttons for the following operations:
Add Book
Check Out Book
Display Book Status
Show All Books
Upon interacting with the buttons, you’ll get feedback (via Toast) and view the results in the
Logcat.
Checking out a book will display: Book checked out successfully: 1984.
Displaying a book's status will show details like title, author, and availability.
Result :
A simple LMS is Built in Android studio using a switch statement in java.