Ccs332 App Development Lab Manual
Ccs332 App Development Lab Manual
Ccs332 App Development Lab Manual
LIST OF EXPERIMENTS
EXPERIMEN PAGE
EXPERIMENT NAME
T NUMBER NO
I Cycle-MS Excel
EX NO :1 BMI CALCULATOR APPLICATION USING
REACTJS
EX NO: 2 BUILD A CROSS PLATFORM APPLICATION
FOR A SIMPLE EXPENSE MANAGER
EX NO : 3
a)
EX.NO : 4 b)
c)
a)
EX.NO : 5
b)
EX.NO : 6
a)
EX.NO : 7
b)
EX.NO : 8
4
AIM :
To build a cross platform application for BMI calculator application using
REACT NATIVE JS.
PROCEDURE :
REACTJS INSTALLATION
1. NodeJS and NPM
2. React and React DOM
3. Webpack
4. Babel
After creating a package.json file, you need to install react and its DOM
packages using the following npm command.
npm install react react-dom --save
6
Let us check the current version of Node and NPM in the system.
2.3 INSTALLATION
Install REACT
We can install React using npm package manager by using the following
command. There is no need to worry about the complexity of React installation.
The create-react-app npm package manager will manage everything, which
needed for React project.
C:\Users\mca1> npm install -g create-react-app
Create a new React project
Once the React installation is successful, we can create a new React project using
create-react-app command. Here, I choose "reactproject" name for my project.
C:\Users\mca1> create-react-app bmi-calculator-react
C:\Users\mca1> npx create-react-bmi-calculator-react
The above command will take some time to install the React and create a new
project with the name "reactproject."
7
The React project is created successfully on our system. Now, we need to start
the server so that we can access the application on the browser. Type the
following command in the terminal window.
1. $ cd Desktop
2. $ npm start
NPM is a package manager which starts the server and access the application at
default server http://localhost:3000.
Fig.,1.2 React url page
Next, open the project on Code editor. Here, I am using Visual Studio Code. Our
project's default structure looks like as below image.
Requirements of Application:
a) Create a workspace with VS Code
b) Design the general layout with HTML & CSS
c) Create the required components with React JS.
8
SOURCE CODE
Index.js
9
//App.js
import React, { useState } from 'react';
import './App.css';
function BmiCalculator() {
const [heightValue, setHeightValue] = useState('');
const [weightValue, setWeightValue] = useState('');
const [bmiValue, setBmiValue] = useState('');
const [bmiMessage, setBmiMessage] = useState('');
return (
<div className="container">
<h1>GeeksforGeeks BMI Calculator</h1>
<div className="input-container">
<label htmlFor="height">Enter Your Height (cm):</label>
<input
type="number"
id="height"
value={heightValue}
onChange={(e) => setHeightValue(e.target.value)}
/>
</div>
<div className="input-container">
<label htmlFor="weight">Enter Your Weight (kg):</label>
<input
type="number"
id="weight"
value={weightValue}
10
OUTPUT :
RESULT :
The cross-platform application for BMI calculator application using REACT NATIVE
JS was built and the desired output was displayed.
12
EX NO: 2
BUILD A CROSS PLATFORM APPLICATION FOR A
DATE : SIMPLE EXPENSE MANAGER
Aim:
To build a cross platform application for a simple expense
manager which allows entering expenses and income on each
day and display category wise weekly income and expenses.
PROCEDURE:
Step 1: Initialize state variables using `useState` for
`transactions`, `amount`,
`category`, and `transactionType`.
Step 2: When the "Add Transaction" button is clicked.
Step 3: Check if both `amount` and `category` fields have
values.
Step 4: If they do:
Step 5: Create a new transaction object with type, amount,
category, and the
current date.
Step 6: Add this transaction to the `transactions` array using
`setTransactions`.
Step 7: Reset `amount` and `category` to empty strings.
Step 8: `calculateWeeklyReport` function.
Step 9: Iterate through `transactions`.
Step 10: Group transactions by category, summing their
income and expenses
separately.
Step 11: Construct an object containing categories with their
respective income
and expenses for the week.
Step 12: Display input fields for `amount`, `category`, and a
dropdown for
`transactionType`.
Step 13: Allow users to input values for these fields.
Step 14: Provide an "Add Transaction" button to add
transactions based on user
input.
Step 15: Show a categorized list of income and expenses for
the week, generated
from `calculateWeeklyReport`.
13
PROGRAM:
import React, { useState } from 'react';
const ExpenseManager = () => {
const [transactions, setTransactions] = useState([]);
const [amount, setAmount] = useState('');
const [category, setCategory] = useState('');
const [transactionType, setTransactionType] =
useState('Expense');
const addTransaction = () => {
if (amount && category) {
const newTransaction = {
type: transactionType,
amount: parseFloat(amount),
category,
date: new Date().toISOString(),
};
setTransactions([...transactions, newTransaction]);
setAmount('');
setCategory('');
}
};
const calculateWeeklyReport = () => {
const categories = transactions.reduce((acc, transaction) => {
const { category, type, amount } = transaction;
acc[category] = acc[category] || { income: 0, expense: 0 };
acc[category][type.toLowerCase()] += amount;
return acc;
}, {});
return Object.entries(categories).map(([category, { income,
expense }]) => ({
category,
income,
expense,
}));
};
return (
<div>
<h1>Expense Manager</h1>
<label>
Amount:
<input
type="number"
value={amount}
14
);
}
export default App;
16
OUTPUT:
Result:
The cross-platform application for a income-expense displayer
using react-native was built successfully.
17
AIM :
To Design and develop a cross platform application for day-
to-day task (to-do) management.
PROCEDURE:
Step 1: Initialize State:
- Initialize the state variables task and tasks using the
useState hook.
Step 2: Add Task:
- Create the addTask function to add a new task to the
tasks array.
- Check if the task is not empty before adding.
- Update the state with the new task and reset the input.
Step 3: Remove Task:
- Create the removeTask function to remove a task from
the tasks array.
- Use the filter method to create a new array excluding the
task with the specified taskId.
- Update the state with the new array
Step 4: Render UI:
- Render the UI with input fields, buttons, and the task list.
- Map through the tasks array to display each task along
with a remove button.
Step 5: Styles:
- Define the styles object for consistent styling throughout
the application.
Step 6: Component Structure:
- The `App` component is the main entry point and
encapsulates the entire application structure.
Step 7: Execution:
- Ensure the required React Native components and
environment are properly set up to run the app.
18
PROGRAM:
import React, { useState } from 'react';
const TodoApp = () => {
const [tasks, setTasks] = useState([]);
const [newTask, setNewTask] = useState('');
const handleInputChange = (event) => {
setNewTask(event.target.value);
};
const addTask = () => {
if (newTask.trim() !== '') {
setTasks([...tasks, newTask]);
setNewTask('');
}
};
const deleteTask = (index) => {
const updatedTasks = [...tasks];
updatedTasks.splice(index, 1);
setTasks(updatedTasks);
};
return (
<div>
<h1>To-Do List</h1>
<ul>
{tasks.map((task, index) => (
<li key={index}>
{task}
<button onClick={() => deleteTask(index)}>Delete</button>
</li>
))}
</ul>
<div>
<input
type="text"
value={newTask}
onChange={handleInputChange}
placeholder="Add a task..."
/>
<button onClick={addTask}>Add Task</button>
</div>
</div>
);
};
export default TodoApp;
19
PROCEDURE TO CODE :
20
21
OUTPUT :
Result:
The cross platform application for a day to day task
management using react native was built successfully.