Omkar Android
Omkar Android
package com.example.welcome
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.welcome.ui.theme.WelcomeTheme
@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Welcome $name!",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
WelcomeTheme {
Greeting("Omkar")
}
}
Create an application to print first and last names as passed to function and print both First and last
name after concatenation.
package com.example.concatenatename
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.concatenatename.ui.theme.ConcatenateNameTheme
modifier = Modifier.padding(innerPadding)
)
}
}
}
}
}
@Composable
fun Greeting(fname: String,lname:String, modifier: Modifier = Modifier) {
Text(
text = "Hello $fname $lname",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
ConcatenateNameTheme {
Greeting("Omkar","Gilbile")
}
}
Create an application for simple calculations(Add, subtract, multiply, divide, mod) using function.
package com.example.calculator
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.calculator.ui.theme.CalculatorTheme
@Composable
fun Greeting(num1: Int,num2:Int, modifier: Modifier = Modifier) {
val add = num1 + num2
val sub = num1 - num2
val mult = num1 * num2
val div = num1 / num2
val mods=num1 % num2
Text(
text = "Addition of two number is: $add \n" +
"Subtraction of two number is: $sub \n"+
"Multiplication of two number is: $mult \n"+
"Division of two number is: $div \n"+
"Modulus of two number is: $mods ",
modifier = modifier
)
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
CalculatorTheme {
Greeting(20,5)
}
}
Create an application using if else or while to calculate the bill discount based on the purchase
amount.
package com.example.discount
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.discount.ui.theme.DiscountTheme
@Composable
fun DiscountCalculator(modifier: Modifier = Modifier) {
var amount by remember { mutableStateOf(TextFieldValue("")) }
var discountMessage by remember { mutableStateOf("") }
Column(
modifier = modifier
.fillMaxSize()
.padding(16.dp),
verticalArrangement = Arrangement.spacedBy(10.dp)
){
Text(text = "Enter Purchase Amount:")
BasicTextField(
value = amount,
onValueChange = { amount = it },
modifier = Modifier
.fillMaxWidth()
.padding(10.dp)
)
Button(
onClick = {
val purchaseAmount = amount.text.toDoubleOrNull() ?: 0.0
discountMessage = calculateDiscount(purchaseAmount)
}
){
Text(text = "Calculate Discount")
}
if (discountMessage.isNotEmpty()) {
Text(text = discountMessage)
}
}
}
@Preview(showBackground = true)
@Composable
fun DiscountCalculatorPreview() {
DiscountTheme {
DiscountCalculator()
}
}
Create an application using row, column and box to print your name, university, city, education
qualifications with there year of passing and percentage. Apply proper background image to
the application.
package com.example.myself
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.myself.ui.theme.MyselfTheme
@Composable
fun UserProfileScreen(modifier: Modifier = Modifier) {
Box(modifier = modifier.fillMaxSize()) {
// Background Image
Image(
painter = painterResource(id = R.drawable.background),
contentDescription = "Background Image",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
)
// Content Layout
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
){
Text(
text = "My Profile",
fontSize = 28.sp,
style = MaterialTheme.typography.headlineLarge
)
Spacer(modifier = Modifier.height(16.dp))
Column(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
horizontalAlignment = Alignment.Start
){
Text(text = "Name: Omkar Gilbile", fontSize = 20.sp)
Text(text = "University: JSPM University", fontSize = 20.sp)
Text(text = "City: Pune", fontSize = 20.sp)
Spacer(modifier = Modifier.height(16.dp))
@Composable
fun EducationRow(qualification: String, year: String, percentage: String) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 4.dp),
horizontalArrangement = Arrangement.SpaceBetween
){
Text(text = qualification, fontSize = 18.sp)
Text(text = year, fontSize = 18.sp)
Text(text = percentage, fontSize = 18.sp)
}
}
@Preview(showBackground = true)
@Composable
fun UserProfileScreenPreview() {
MyselfTheme {
UserProfileScreen()
}
}
Suppose that you are a CEO of company, all the developers, team members and their respected team
members have submitted their data( name , email, mobno, dob, blood group) to you now it's your
responsibility to give them that customized message according to their date of birth. In this version
of the application minimum two developers, 1project manager and one team leader data is required.
And the data is name, email, mob no, date of birth, blood group
Wish them their birthday when it occurs using following style, if the blood grp is
• Ab+ golden
Note - the colours should be same with the in color .XML file proper name use
package com.example.blood
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.blood.ui.theme.BloodTheme
import java.text.SimpleDateFormat
import java.util.*
@Composable
fun BirthdayScreen(modifier: Modifier = Modifier) {
val teamMembers = listOf(
Person("Alice Johnson", "[email protected]", "9876543210", "1995-02-13", "A+"),
Person("Bob Smith", "[email protected]", "8765432109", "1992-06-20", "B+"),
Person("Charlie Brown", "[email protected]", "7654321098", "1989-08-15", "O"),
Person("David Miller", "[email protected]", "6543210987", "1997-12-25", "AB+")
)
Box(modifier = modifier.fillMaxSize()) {
// Background Image
Image(
painter = painterResource(id = R.drawable.birthday_bg),
contentDescription = "Birthday Background",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop
)
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally
){
Text(
text = " Birthday Wishes ",
fontSize = 26.sp,
style = MaterialTheme.typography.headlineLarge
)
Spacer(modifier = Modifier.height(16.dp))
Box(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
contentAlignment = Alignment.Center
){
Text(
text = " Happy Birthday, ${member.name}! ",
fontSize = 20.sp,
color = textColor
)
}
}
@Preview(showBackground = true)
@Composable
fun BirthdayScreenPreview() {
BloodTheme {
BirthdayScreen()
}
}